summaryrefslogtreecommitdiff
path: root/test/lex.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:31:20 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2018-01-20 17:31:20 +0000
commit0dd48e83fbc246a881609b4c18ce10001ba1cc1a (patch)
tree7494cc81744799ab88f1503ac5ff044be2fcf4a5 /test/lex.c
parente220b0fc2ede1dcbbe7e6e62c256e2ec297f26a3 (diff)
downloadlibcss-0dd48e83fbc246a881609b4c18ce10001ba1cc1a.tar.gz
libcss-0dd48e83fbc246a881609b4c18ce10001ba1cc1a.tar.bz2
Add support for logging via libnslog.
Release builds minumum compiled level is warning. Debug builds minimum compiled level is debug.
Diffstat (limited to 'test/lex.c')
-rw-r--r--test/lex.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/lex.c b/test/lex.c
index cce8ded..92db574 100644
--- a/test/lex.c
+++ b/test/lex.c
@@ -110,6 +110,20 @@ static void printToken(const css_token *token)
#endif
}
+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)
{
parserutils_inputstream *stream;
@@ -127,6 +141,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(parserutils_inputstream_create("UTF-8",
CSS_CHARSET_DICTATED,css__charset_extract,
@@ -190,6 +214,8 @@ int main(int argc, char **argv)
parserutils_inputstream_destroy(stream);
}
+ nslog_cleanup();
+
printf("PASS\n");
return 0;