X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Flog.c;h=0bdb6927c623bc770c686f7650aa28d1600ec520;hb=1608c9d4a753e66c7e46dc2a5be69079470ec75b;hp=bad2cb25b95b51af3f198a6c55135e61c5e54757;hpb=b4b40d73ad3a8e5199da8cd8eeac83780fa8b981;p=platform%2Fupstream%2Flibxkbcommon.git diff --git a/test/log.c b/test/log.c index bad2cb2..0bdb692 100644 --- a/test/log.c +++ b/test/log.c @@ -21,15 +21,15 @@ * DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include +#include "config.h" #include "test.h" -#include "xkb-priv.h" +#include "context.h" +#include "messages-codes.h" +#ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wmissing-format-attribute" +#endif static const char * log_level_to_string(enum xkb_log_level level) @@ -56,7 +56,7 @@ log_fn(struct xkb_context *ctx, enum xkb_log_level level, { 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); @@ -75,37 +75,37 @@ main(void) struct xkb_context *ctx; int ret; - ret = setenv("XKB_LOG", "warn", 1); + ret = setenv("XKB_LOG_LEVEL", "warn", 1); assert(ret == 0); - ret = setenv("XKB_VERBOSITY", "5", 1); + ret = setenv("XKB_LOG_VERBOSITY", "5", 1); assert(ret == 0); - ctx = xkb_context_new(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); - - 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_vrb(ctx, 5, "first verbose 5\n"); - - xkb_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_vrb(ctx, 6, "second verbose 6\n"); - - xkb_set_log_verbosity(ctx, 0); - xkb_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_vrb(ctx, 0, "third verbose 0\n"); + xkb_context_set_user_data(ctx, &log_string); + xkb_context_set_log_fn(ctx, log_fn); + + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "first warning: %d\n", 87); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "first info\n"); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "first debug: %s\n", "hello"); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "first error: %lu\n", 115415UL); + log_vrb(ctx, 5, XKB_LOG_MESSAGE_NO_ID, "first verbose 5\n"); + + xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG); + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "second warning: %d\n", 87); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "second debug: %s %s\n", "hello", "world"); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "second info\n"); + log_err(ctx, XKB_ERROR_MALFORMED_NUMBER_LITERAL, "second error: %lu\n", 115415UL); + log_vrb(ctx, 6, XKB_LOG_MESSAGE_NO_ID, "second verbose 6\n"); + + xkb_context_set_log_verbosity(ctx, 0); + xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL); + log_warn(ctx, XKB_LOG_MESSAGE_NO_ID, "third warning: %d\n", 87); + log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "third debug: %s %s\n", "hello", "world"); + log_info(ctx, XKB_LOG_MESSAGE_NO_ID, "third info\n"); + log_err(ctx, XKB_LOG_MESSAGE_NO_ID, "third error: %lu\n", 115415UL); + log_vrb(ctx, 0, XKB_LOG_MESSAGE_NO_ID, "third verbose 0\n"); printf("%s", log_string.item); @@ -116,7 +116,7 @@ main(void) "warning: second warning: 87\n" "debug: second debug: hello world\n" "info: second info\n" - "error: second error: 115415\n")); + "error: [XKB-034] second error: 115415\n")); xkb_context_unref(ctx); darray_free(log_string);