--- 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)
|