From 8052642eadfb95b244f978b10889dff51f9133f5 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 10 Jun 2017 20:48:38 +0100 Subject: Rework to only allocate one thing in the corked state and nothing in the uncorked state --- test/basic.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'test/basic.c') diff --git a/test/basic.c b/test/basic.c index fd40633..7626dd8 100644 --- a/test/basic.c +++ b/test/basic.c @@ -13,21 +13,29 @@ NSLOG_DEFINE_CATEGORY(test, "Test category"); -static void test_render_function(void *ctx, nslog_entry_t *log) +static void test_render_function( + void *_ctx, nslog_entry_context_t *ctx, + const char *fmt, va_list args) { (void)ctx; - fprintf(stderr, "%s %s:%d [%s] %s() %s\n", - nslog_level_name(log->level), - log->filename, log->lineno, - log->category->name, - log->funcname, - log->message); + fprintf(stderr, "%s %s:%d [%s] %s() ", + nslog_level_name(ctx->level), + ctx->filename, ctx->lineno, + ctx->category->name, + ctx->funcname); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); } int main(int argc, char **argv) { nslog_set_render_callback(test_render_function, NULL); + NSLOG(test, INFO, "Pre-uncorking"); + fprintf(stderr, "About to nslog_uncork()\n"); nslog_uncork(); + fprintf(stderr, "Uncorked now\n"); NSLOG(test, WARN, "argc=%d", argc); + for (int i = 0; i < argc; ++i) + NSLOG(test, WARN, "argv[%d] = %s", i, argv[i]); return 0; } -- cgit v1.2.3