diff options
author | Daniel Stone <daniel@fooishbar.org> | 2012-08-08 14:01:46 +0200 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2012-08-08 16:23:31 +0200 |
commit | 5e276adb9209749f1b5152853c640ec444df7051 (patch) | |
tree | d6c77df81fe9dc3c8d470903c059e05330b4824c /test | |
parent | ba8458a9fd580d80d127ed1768f8f1d4a51ef251 (diff) |
Add xkb_log_level enum rather than using syslog
Instead of relying on people including syslog.h, add our own
XKB_LOG_LEVEL_* defines.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/common.c | 3 | ||||
-rw-r--r-- | test/log.c | 13 | ||||
-rw-r--r-- | test/rulescomp.c | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/test/common.c b/test/common.c index c1f9786..2d49824 100644 --- a/test/common.c +++ b/test/common.c @@ -35,7 +35,6 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/syslog.h> #include "xkbcommon/xkbcommon.h" #include "test.h" @@ -102,7 +101,7 @@ test_get_context(void) xkb_context_include_path_append(ctx, test_get_path("")); - xkb_set_log_priority(ctx, LOG_DEBUG); + xkb_set_log_priority(ctx, XKB_LOG_LEVEL_DEBUG); xkb_set_log_verbosity(ctx, 101); return ctx; @@ -25,7 +25,6 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <syslog.h> #include "test.h" #include "xkb-priv.h" @@ -36,13 +35,13 @@ static const char * priority_to_string(int priority) { switch (priority) { - case LOG_ERR: + case XKB_LOG_LEVEL_ERROR: return "error"; - case LOG_WARNING: + case XKB_LOG_LEVEL_WARNING: return "warning"; - case LOG_INFO: + case XKB_LOG_LEVEL_INFO: return "info"; - case LOG_DEBUG: + case XKB_LOG_LEVEL_DEBUG: return "debug"; } @@ -89,7 +88,7 @@ main(void) log_err(ctx, "first error: %lu\n", 115415UL); log_lvl(ctx, 5, "first verbose 5\n"); - xkb_set_log_priority(ctx, LOG_DEBUG); + xkb_set_log_priority(ctx, XKB_LOG_LEVEL_DEBUG); log_warn(ctx, "second warning: %d\n", 87); log_dbg(ctx, "second debug: %s %s\n", "hello", "world"); log_info(ctx, "second info\n"); @@ -97,7 +96,7 @@ main(void) log_lvl(ctx, 6, "second verbose 6\n"); xkb_set_log_verbosity(ctx, 0); - xkb_set_log_priority(ctx, -1); + xkb_set_log_priority(ctx, XKB_LOG_LEVEL_CRITICAL); log_warn(ctx, "third warning: %d\n", 87); log_dbg(ctx, "third debug: %s %s\n", "hello", "world"); log_info(ctx, "third info\n"); diff --git a/test/rulescomp.c b/test/rulescomp.c index 8eb9464..bed0bb5 100644 --- a/test/rulescomp.c +++ b/test/rulescomp.c @@ -70,13 +70,21 @@ static void benchmark(struct xkb_context *context) { struct timespec start, stop, elapsed; + enum xkb_log_level old_prio = xkb_get_log_priority(context); + int old_verb = xkb_get_log_verbosity(context); int i; + xkb_set_log_priority(context, XKB_LOG_LEVEL_CRITICAL); + xkb_set_log_verbosity(context, 0); + clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < BENCHMARK_ITERATIONS; i++) assert(test_rmlvo_silent(context, "evdev", "", "us", "", "")); clock_gettime(CLOCK_MONOTONIC, &stop); + xkb_set_log_priority(context, old_prio); + xkb_set_log_verbosity(context, old_verb); + elapsed.tv_sec = stop.tv_sec - start.tv_sec; elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec; if (elapsed.tv_nsec < 0) { |