From 0dd48e83fbc246a881609b4c18ce10001ba1cc1a Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 20 Jan 2018 17:31:20 +0000 Subject: Add support for logging via libnslog. Release builds minumum compiled level is warning. Debug builds minimum compiled level is debug. --- test/parse.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/parse.c') diff --git a/test/parse.c b/test/parse.c index 0692fc7..c7017a9 100644 --- a/test/parse.c +++ b/test/parse.c @@ -66,6 +66,20 @@ static css_error event_handler(css_parser_event type, return CSS_OK; } +static void test_logger( + void *_ctx, nslog_entry_context_t *ctx, + const char *fmt, + va_list args) +{ + UNUSED(_ctx); + fprintf(stderr, "%s: %s: %s:%i: ", + nslog_level_name(ctx->level), + ctx->category->description, + ctx->filename, ctx->lineno); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); +} + int main(int argc, char **argv) { css_parser_optparams params; @@ -82,6 +96,16 @@ int main(int argc, char **argv) return 1; } + if (nslog_set_render_callback(test_logger, NULL) != NSLOG_NO_ERROR) { + printf("Unable to set log render callback\n"); + return 1; + } + + if (nslog_uncork() != NSLOG_NO_ERROR) { + printf("Failed to uncork log.\n"); + return 1; + } + for (i = 0; i < ITERATIONS; i++) { assert(css__parser_create("UTF-8", CSS_CHARSET_DICTATED, &parser) == CSS_OK); @@ -129,6 +153,8 @@ int main(int argc, char **argv) } + nslog_cleanup(); + printf("PASS\n"); return 0; -- cgit v1.2.3