X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Flog.c;h=384fabcb08227b91889df4d6c30590a558c020f8;hb=399aa888e0e5b2fc37bde5ec002211094f0c0448;hp=78d97ee3c411dc4437ed3ceebc1c76fa2a4a4752;hpb=89723b7cb7198d76990110bd3c4efae0dba97765;p=platform%2Fupstream%2Flibxkbcommon.git diff --git a/test/log.c b/test/log.c index 78d97ee..384fabc 100644 --- a/test/log.c +++ b/test/log.c @@ -1,5 +1,5 @@ /* - * Copyright © 2012 Ran Benita + * Copyright © 2012 Ran Benita * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,28 +21,28 @@ * DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include +#include "config.h" #include "test.h" -#include "xkb-priv.h" +#include "context.h" +#ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-format-attribute" +#endif static const char * -priority_to_string(int priority) +log_level_to_string(enum xkb_log_level level) { - switch (priority) { - case LOG_ERR: + switch (level) { + case XKB_LOG_LEVEL_CRITICAL: + return "critical"; + 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"; } @@ -50,17 +50,18 @@ priority_to_string(int priority) } ATTR_PRINTF(3, 0) static void -log_fn(struct xkb_context *ctx, int priority, const char *fmt, va_list args) +log_fn(struct xkb_context *ctx, enum xkb_log_level level, + const char *fmt, va_list args) { char *s; int size; - darray_char *ls = xkb_get_user_data(ctx); + darray_char *ls = xkb_context_get_user_data(ctx); assert(ls); size = vasprintf(&s, fmt, args); assert(size != -1); - darray_append_string(*ls, priority_to_string(priority)); + darray_append_string(*ls, log_level_to_string(level)); darray_append_lit(*ls, ": "); darray_append_string(*ls, s); free(s); @@ -73,36 +74,37 @@ main(void) struct xkb_context *ctx; int ret; - ret = setenv("XKB_LOG", "warn", 1); - ret = setenv("XKB_VERBOSITY", "5", 1); + ret = setenv("XKB_LOG_LEVEL", "warn", 1); assert(ret == 0); - ctx = test_get_context(); + ret = setenv("XKB_LOG_VERBOSITY", "5", 1); + assert(ret == 0); + ctx = test_get_context(0); assert(ctx); darray_init(log_string); - xkb_set_user_data(ctx, &log_string); - xkb_set_log_fn(ctx, log_fn); + xkb_context_set_user_data(ctx, &log_string); + xkb_context_set_log_fn(ctx, log_fn); log_warn(ctx, "first warning: %d\n", 87); log_info(ctx, "first info\n"); log_dbg(ctx, "first debug: %s\n", "hello"); log_err(ctx, "first error: %lu\n", 115415UL); - log_lvl(ctx, 5, "first verbose 5\n"); + log_vrb(ctx, 5, "first verbose 5\n"); - xkb_set_log_priority(ctx, LOG_DEBUG); + xkb_context_set_log_level(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"); log_err(ctx, "second error: %lu\n", 115415UL); - log_lvl(ctx, 6, "second verbose 6\n"); + log_vrb(ctx, 6, "second verbose 6\n"); - xkb_set_log_verbosity(ctx, 0); - xkb_set_log_priority(ctx, -1); + xkb_context_set_log_verbosity(ctx, 0); + xkb_context_set_log_level(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"); log_err(ctx, "third error: %lu\n", 115415UL); - log_lvl(ctx, 0, "third verbose 0\n"); + log_vrb(ctx, 0, "third verbose 0\n"); printf("%s", log_string.item);