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-auto.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/parse-auto.c') diff --git a/test/parse-auto.c b/test/parse-auto.c index 58ccf9a..a298864 100644 --- a/test/parse-auto.c +++ b/test/parse-auto.c @@ -99,6 +99,20 @@ static void destroy_expected(line_ctx *ctx) } } +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) { line_ctx ctx; @@ -108,6 +122,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; + } + ctx.buflen = css__parse_filesize(argv[1]); if (ctx.buflen == 0) return 1; @@ -143,6 +167,8 @@ int main(int argc, char **argv) assert(fail_because_lwc_leaked == false); + nslog_cleanup(); + printf("PASS\n"); return 0; -- cgit v1.2.3