context: remove mostly useless log wrappers Just use xkb_log directly. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
diff --git a/src/context.c b/src/context.c
index 6ecc4b3..3c0cab4 100644
--- a/src/context.c
+++ b/src/context.c
@@ -352,11 +352,14 @@ xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom)
}
void
-xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
+xkb_log(struct xkb_context *ctx, enum xkb_log_level level, int verbosity,
const char *fmt, ...)
{
va_list args;
+ if (ctx->log_level < level || ctx->log_verbosity < verbosity)
+ return;
+
va_start(args, fmt);
ctx->log_fn(ctx, level, fmt, args);
va_end(args);
diff --git a/src/context.h b/src/context.h
index 67e68d9..580acba 100644
--- a/src/context.h
+++ b/src/context.h
@@ -63,20 +63,10 @@ xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
char *
xkb_context_get_buffer(struct xkb_context *ctx, size_t size);
-ATTR_PRINTF(3, 4) void
-xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
+ATTR_PRINTF(4, 5) void
+xkb_log(struct xkb_context *ctx, enum xkb_log_level level, int verbosity,
const char *fmt, ...);
-#define xkb_log_cond_level(ctx, level, ...) do { \
- if (xkb_context_get_log_level(ctx) >= (level)) \
- xkb_log((ctx), (level), __VA_ARGS__); \
-} while (0)
-
-#define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \
- if (xkb_context_get_log_verbosity(ctx) >= (vrb)) \
- xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
-} while (0)
-
const char *
xkb_context_get_default_rules(struct xkb_context *ctx);
@@ -99,17 +89,17 @@ xkb_context_get_default_options(struct xkb_context *ctx);
* result in an error, though.
*/
#define log_dbg(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_DEBUG, __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_DEBUG, 0, __VA_ARGS__)
#define log_info(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_INFO, __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_INFO, 0, __VA_ARGS__)
#define log_warn(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_WARNING, __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_WARNING, 0, __VA_ARGS__)
#define log_err(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_ERROR, __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_ERROR, 0, __VA_ARGS__)
#define log_wsgo(ctx, ...) \
- xkb_log_cond_level((ctx), XKB_LOG_LEVEL_CRITICAL, __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_CRITICAL, 0, __VA_ARGS__)
#define log_vrb(ctx, vrb, ...) \
- xkb_log_cond_verbosity((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
+ xkb_log((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
/*
* Variants which are prefixed by the name of the function they're
diff --git a/src/xkbcomp/scanner.c b/src/xkbcomp/scanner.c
index 591f1f5..48df488 100644
--- a/src/xkbcomp/scanner.c
+++ b/src/xkbcomp/scanner.c
@@ -28,8 +28,8 @@
static void
scanner_log(enum xkb_log_level level, struct scanner *s, const char *msg)
{
- xkb_log_cond_level(s->ctx, level, "%s:%d:%d: %s\n", s->file_name,
- s->token_line, s->token_column, msg);
+ xkb_log(s->ctx, level, 0, "%s:%d:%d: %s\n", s->file_name,
+ s->token_line, s->token_column, msg);
}
int