Index: ossp-pkg/l2/l2_stream.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v rcsdiff -q -kk '-r1.8' '-r1.9' -u '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v' 2>/dev/null --- l2_stream.c 2001/09/04 13:52:59 1.8 +++ l2_stream.c 2001/09/04 14:17:11 1.9 @@ -65,7 +65,7 @@ { int i; - if (st == NULL || id == '\0' || cb != NULL) + if (st == NULL || id == '\0' || cb == NULL) return L2_ERROR; for (i = 0; i < L2_MAX_FORMATTERS && st->formatters[i].cb != NULL; i++) ; Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/09/03 13:43:33 1.6 +++ l2_test.c 2001/09/04 14:17:11 1.7 @@ -42,6 +42,24 @@ exit(1); } +l2_result_t formatter( + l2_context_t *ctx, + const char id, + const char *param, + char *bufptr, + size_t bufsize, + size_t *buflen, + va_list *ap +) +{ + int i; + + i = va_arg(*ap, int); + sprintf(bufptr, "[%d/%s]", i, param); + *buflen = strlen(bufptr); + return L2_OK; +} + int main(int argc, char *argv[]) { l2_channel_t *chBuf; @@ -79,7 +97,10 @@ if (l2_stream_levels(st, L2_LEVEL_UPTO(L2_LEVEL_WARNING), NULL) != L2_OK) die("failed to set global logging level"); - if (l2_stream_log(st, L2_LEVEL_PANIC, "test %s", "foo") != L2_OK) + if (l2_stream_formatter(st, 'k', formatter, NULL) != L2_OK) + die("failed to configure formatter for %%x"); + + if (l2_stream_log(st, L2_LEVEL_PANIC, "test %s %{foo}k", "foo", 12345) != L2_OK) die("failed to log message to stream"); if (l2_stream_destroy(st) != L2_OK)