Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/131b33a2d7ee34e0c4113b7f3e62388bd7654282
...commit
http://git.netsurf-browser.org/libcss.git/commit/131b33a2d7ee34e0c4113b7f3e62388bd7654282
...tree
http://git.netsurf-browser.org/libcss.git/tree/131b33a2d7ee34e0c4113b7f3e62388bd7654282
The branch, tlsa/logging has been created
at 131b33a2d7ee34e0c4113b7f3e62388bd7654282 (commit)
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=131b33a2d7ee34e0c4113b7f3e62388bd7654282
commit 131b33a2d7ee34e0c4113b7f3e62388bd7654282
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Selection: Add debug logging for pre-selection style sharing.
diff --git a/src/select/select.c b/src/select/select.c
index 6b5225a..6a34e69 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -22,6 +22,7 @@
#include "select/propset.h"
#include "select/font_face.h"
#include "select/select.h"
+#include "utils/log.h"
#include "utils/parserutilserror.h"
#include "utils/utils.h"
@@ -744,20 +745,18 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
error = state->handler->get_libcss_node_data(state->pw,
share_candidate_node, (void **) (void *) &node_data);
if (error != CSS_OK || node_data == NULL) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: no candidate node data\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: no candidate node data",
+ lwc_string_data(state->element.name));
return error;
}
/* If one node has hints and other doesn't then can't share */
if ((node_data->flags & CSS_NODE_FLAGS_HAS_HINTS) !=
(state->node_data->flags & CSS_NODE_FLAGS_HAS_HINTS)) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: have hints mismatch\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: have hints mismatch",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -766,10 +765,9 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
if ((node_data->flags & CSS_NODE_FLAGS__PSEUDO_CLASSES_MASK) !=
(state->node_data->flags &
CSS_NODE_FLAGS__PSEUDO_CLASSES_MASK)) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: different pseudo classes\n",
- lwc_string_data(state->element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: different pseudo classes",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -781,22 +779,17 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
CSS_NODE_FLAGS_TAINT_ATTRIBUTE |
CSS_NODE_FLAGS_TAINT_SIBLING |
CSS_NODE_FLAGS_HAS_INLINE_STYLE)) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: candidate flags: %s%s%s%s\n",
- lwc_string_data(state->element.name),
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS) ?
- "PSEUDOCLASS" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_ATTRIBUTE) ?
- " ATTRIBUTE" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_TAINT_SIBLING) ?
- " SIBLING" : "",
- (node_data->flags &
- CSS_NODE_FLAGS_HAS_INLINE_STYLE) ?
- " INLINE_STYLE" : "");
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: candidate flags: %s%s%s%s",
+ lwc_string_data(state->element.name),
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_PSEUDO_CLASS) ?
+ "PSEUDOCLASS" : "",
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_ATTRIBUTE) ?
+ " ATTRIBUTE" : "",
+ (node_data->flags & CSS_NODE_FLAGS_TAINT_SIBLING) ?
+ " SIBLING" : "",
+ (node_data->flags & CSS_NODE_FLAGS_HAS_INLINE_STYLE) ?
+ " INLINE_STYLE" : "");
return CSS_OK;
}
@@ -809,10 +802,9 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
} else if (share_candidate_id != NULL) {
lwc_string_unref(share_candidate_id);
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: candidate id\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: candidate id",
lwc_string_data(state->element.name));
-#endif
return CSS_OK;
}
@@ -826,10 +818,9 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
}
if (state->n_classes != share_candidate_n_classes) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: class count mismatch\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: class count mismatch",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
@@ -843,20 +834,18 @@ static css_error
css_select_style__get_sharable_node_data_for_candidate(
share_candidate_classes[i],
&match) == lwc_error_ok &&
match == false) {
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: class mismatch\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: class mismatch",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
}
if (node_data->flags & CSS_NODE_FLAGS_HAS_HINTS) {
/* TODO: check hints match. For now, just prevent sharing */
-#ifdef DEBUG_STYLE_SHARING
- printf(" \t%s\tno share: hints\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: hints",
lwc_string_data(state->element.name));
-#endif
goto cleanup;
}
@@ -929,15 +918,16 @@ static css_error css_select_style__get_sharable_node_data(
* and if we get a non-NULL "matched" then return.
*
* Check overhead is worth cost. */
-#ifdef DEBUG_STYLE_SHARING
-printf(" \t%s\tno share: node id (%s)\n",
lwc_string_data(state->element.name), lwc_string_data(state->id));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: node id (%s)",
+ lwc_string_data(state->element.name),
+ lwc_string_data(state->id));
return CSS_OK;
}
if (state->node_data->flags & CSS_NODE_FLAGS_HAS_INLINE_STYLE) {
-#ifdef DEBUG_STYLE_SHARING
-printf(" \t%s\tno share: inline style\n");
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: inline style",
+ lwc_string_data(state->element.name));
return CSS_OK;
}
@@ -977,7 +967,7 @@ printf(" \t%s\tno share: inline style\n");
}
if (*sharable_node_data != NULL) {
- /* Found style date we can share */
+ /* Found style data we can share */
break;
}
@@ -1204,15 +1194,14 @@ css_error css_select_style(css_select_ctx *ctx, void
*node,
state.results->styles[i] =
css__computed_style_ref(styles[i]);
}
-#ifdef DEBUG_STYLE_SHARING
- printf("style:\t%s\tSHARED!\n",
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tSHARED existing style!",
lwc_string_data(state.element.name));
-#endif
goto complete;
}
-#ifdef DEBUG_STYLE_SHARING
- printf("style:\t%s\tSELECTED\n", lwc_string_data(state.element.name));
-#endif
+ NSLOG(libcss_selection_style_sharing, DBG,
+ "\t%s\tno share: Have to do selection.",
+ lwc_string_data(state.element.name));
/* Not sharing; need to select.
* Base element style is guaranteed to exist
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=0dd48e83fbc246a881609b4c18ce10001ba1cc1a
commit 0dd48e83fbc246a881609b4c18ce10001ba1cc1a
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Add support for logging via libnslog.
Release builds minumum compiled level is warning.
Debug builds minimum compiled level is debug.
diff --git a/Makefile b/Makefile
index a4f0844..4960d28 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,14 @@ ifneq ($(HOST),i586-pc-haiku)
endif
endif
+ifeq ($(VARIANT),debug)
+ NSLOG_MIN_LOG=NSLOG_LEVEL_DEBUG
+else
+ NSLOG_MIN_LOG=NSLOG_LEVEL_WARNING
+endif
+
CFLAGS := -D_BSD_SOURCE -D_DEFAULT_SOURCE \
+ -DNSLOG_COMPILED_MIN_LEVEL=$(NSLOG_MIN_LOG) \
-I$(CURDIR)/include/ -I$(CURDIR)/src \
$(WARNFLAGS) $(CFLAGS)
ifneq ($(GCCVER),2)
@@ -38,11 +45,11 @@ else
CFLAGS := $(CFLAGS) -Dinline="__inline__"
endif
-# Parserutils & wapcaplet
+# NSLog, Parserutils & Wapcaplet
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
ifneq ($(PKGCONFIG),)
- CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) libparserutils libwapcaplet
--cflags)
- LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) libparserutils libwapcaplet
--libs)
+ CFLAGS := $(CFLAGS) $(shell $(PKGCONFIG) libnslog libparserutils
libwapcaplet --cflags)
+ LDFLAGS := $(LDFLAGS) $(shell $(PKGCONFIG) libnslog libparserutils
libwapcaplet --libs)
else
CFLAGS := $(CFLAGS) -I$(PREFIX)/include
LDFLAGS := $(LDFLAGS) -lparserutils -lwapcaplet
diff --git a/README b/README
index 0f45b87..cf3d425 100644
--- a/README
+++ b/README
@@ -20,6 +20,7 @@ Requirements
LibCSS also requires the following libraries to be installed:
+ + LibNSLog
+ LibParserUtils
+ LibWapcaplet
diff --git a/include/libcss/libcss.h b/include/libcss/libcss.h
index 89e83b5..9b0ae5e 100644
--- a/include/libcss/libcss.h
+++ b/include/libcss/libcss.h
@@ -13,6 +13,7 @@ extern "C"
{
#endif
+#include <nslog/nslog.h>
#include <libwapcaplet/libwapcaplet.h>
#include <libcss/errors.h>
@@ -24,6 +25,9 @@ extern "C"
#include <libcss/stylesheet.h>
#include <libcss/font_face.h>
+/** Logging category for LibCSS. */
+NSLOG_DECLARE_CATEGORY(libcss);
+
#ifdef __cplusplus
}
#endif
diff --git a/libcss.pc.in b/libcss.pc.in
index 8df11b4..d1cba65 100644
--- a/libcss.pc.in
+++ b/libcss.pc.in
@@ -6,6 +6,6 @@ includedir=${prefix}/INCLUDEDIR
Name: libcss
Description: CSS parsing and selection library
Version: VERSION
-Requires: libparserutils, libwapcaplet
+Requires: libnslog, libparserutils, libwapcaplet
Libs: -L${libdir} -lcss
Cflags: -I${includedir}
diff --git a/src/utils/Makefile b/src/utils/Makefile
index c317eea..f3fa8fb 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,4 +1,4 @@
# Sources
-DIR_SOURCES := errors.c utils.c
+DIR_SOURCES := errors.c log.c utils.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/utils/log.c b/src/utils/log.c
new file mode 100644
index 0000000..f16c553
--- /dev/null
+++ b/src/utils/log.c
@@ -0,0 +1,17 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2018 Michael Drake <[email protected]>
+ */
+
+#include <stddef.h>
+
+#include "utils/log.h"
+
+NSLOG_DEFINE_CATEGORY(libcss, "LibCSS");
+
+NSLOG_DEFINE_SUBCATEGORY(libcss, libcss_selection, "Selection");
+
+NSLOG_DEFINE_SUBCATEGORY(libcss_selection, libcss_selection_style_sharing,
+ "Computed style sharing");
diff --git a/src/utils/log.h b/src/utils/log.h
new file mode 100644
index 0000000..6579d92
--- /dev/null
+++ b/src/utils/log.h
@@ -0,0 +1,19 @@
+/*
+ * This file is part of LibCSS.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2018 Michael Drake <[email protected]>
+ */
+
+#ifndef css_utils_log_h_
+#define css_utils_log_h_
+
+#include <nslog/nslog.h>
+
+/** Logging sub-category for Selection. */
+NSLOG_DECLARE_CATEGORY(libcss_selection);
+
+/** Logging sub-category for Selection style sharing. */
+NSLOG_DECLARE_CATEGORY(libcss_selection_style_sharing);
+
+#endif
diff --git a/test/csdetect.c b/test/csdetect.c
index b8c8e3f..bbe4307 100644
--- a/test/csdetect.c
+++ b/test/csdetect.c
@@ -22,6 +22,20 @@ typedef struct line_ctx {
bool inenc;
} line_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");
+}
+
static bool handle_line(const char *data, size_t datalen, void *pw);
static void run_test(const uint8_t *data, size_t len, char *expected);
@@ -34,6 +48,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;
@@ -61,6 +85,8 @@ int main(int argc, char **argv)
free(ctx.buf);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
diff --git a/test/css21.c b/test/css21.c
index a29fae1..f8d3891 100644
--- a/test/css21.c
+++ b/test/css21.c
@@ -25,6 +25,20 @@ static css_error resolve_url(void *pw,
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_stylesheet_params params;
@@ -41,6 +55,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;
+ }
+
params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
params.level = CSS_LEVEL_21;
params.charset = "UTF-8";
@@ -153,6 +177,8 @@ int main(int argc, char **argv)
css_stylesheet_destroy(sheet);
}
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
diff --git a/test/lex-auto.c b/test/lex-auto.c
index f4afec3..e7e7c83 100644
--- a/test/lex-auto.c
+++ b/test/lex-auto.c
@@ -42,6 +42,20 @@ static css_token_type string_to_type(const char *data,
size_t len);
static void run_test(const uint8_t *data, size_t len,
exp_entry *exp, size_t explen);
+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;
@@ -51,6 +65,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;
@@ -79,6 +103,8 @@ int main(int argc, char **argv)
free(ctx.buf);
free(ctx.exp);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
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;
diff --git a/test/number.c b/test/number.c
index d255f4c..e3c2c8f 100644
--- a/test/number.c
+++ b/test/number.c
@@ -25,6 +25,20 @@ static void run_test(const uint8_t *data, size_t len,
const char *exp, size_t explen);
static void print_css_fixed(char *buf, size_t len, css_fixed f);
+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;
@@ -34,6 +48,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;
@@ -59,6 +83,8 @@ int main(int argc, char **argv)
free(ctx.buf);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
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;
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;
diff --git a/test/parse2-auto.c b/test/parse2-auto.c
index ee717c3..ea833f9 100644
--- a/test/parse2-auto.c
+++ b/test/parse2-auto.c
@@ -57,6 +57,20 @@ printing_lwc_iterator(lwc_string *str, void *pw)
fail_because_lwc_leaked = true;
}
+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;
@@ -66,6 +80,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;
@@ -99,6 +123,8 @@ int main(int argc, char **argv)
assert(fail_because_lwc_leaked == false);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
diff --git a/test/select.c b/test/select.c
index f21d937..923bf38 100644
--- a/test/select.c
+++ b/test/select.c
@@ -231,6 +231,20 @@ printing_lwc_iterator(lwc_string *str, void *pw)
fail_because_lwc_leaked = true;
}
+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;
@@ -240,6 +254,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;
+ }
+
memset(&ctx, 0, sizeof(ctx));
@@ -261,6 +285,8 @@ int main(int argc, char **argv)
assert(fail_because_lwc_leaked == false);
+ nslog_cleanup();
+
printf("PASS\n");
return 0;
}
-----------------------------------------------------------------------
--
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org