API: add _context prefix to log-related functions

This is to follow the general scheme set by all of the other API
functions.
Since no one is using these functions yet, we don't (actually better
not) add the old names to xkbcommon-compat.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-09-22 10:58:00 +03:00 committed by Daniel Stone
parent be3cbc993e
commit 0dd40125c5
10 changed files with 51 additions and 50 deletions

View File

@ -296,11 +296,11 @@ xkb_context_new(enum xkb_context_flags flags)
/* Environment overwrites defaults. */
env = getenv("XKB_LOG");
if (env)
xkb_set_log_level(ctx, log_level(env));
xkb_context_set_log_level(ctx, log_level(env));
env = getenv("XKB_VERBOSITY");
if (env)
xkb_set_log_verbosity(ctx, log_verbosity(env));
xkb_context_set_log_verbosity(ctx, log_verbosity(env));
if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) &&
!xkb_context_include_path_append_default(ctx)) {
@ -361,40 +361,40 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
}
XKB_EXPORT void
xkb_set_log_fn(struct xkb_context *ctx,
void (*log_fn)(struct xkb_context *ctx,
enum xkb_log_level level,
const char *fmt, va_list args))
xkb_context_set_log_fn(struct xkb_context *ctx,
void (*log_fn)(struct xkb_context *ctx,
enum xkb_log_level level,
const char *fmt, va_list args))
{
ctx->log_fn = (log_fn ? log_fn : default_log_fn);
}
XKB_EXPORT enum xkb_log_level
xkb_get_log_level(struct xkb_context *ctx)
xkb_context_get_log_level(struct xkb_context *ctx)
{
return ctx->log_level;
}
XKB_EXPORT void
xkb_set_log_level(struct xkb_context *ctx, enum xkb_log_level level)
xkb_context_set_log_level(struct xkb_context *ctx, enum xkb_log_level level)
{
ctx->log_level = level;
}
XKB_EXPORT int
xkb_get_log_verbosity(struct xkb_context *ctx)
xkb_context_get_log_verbosity(struct xkb_context *ctx)
{
return ctx->log_verbosity;
}
XKB_EXPORT void
xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity)
xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity)
{
ctx->log_verbosity = verbosity;
}
XKB_EXPORT void *
xkb_get_user_data(struct xkb_context *ctx)
xkb_context_get_user_data(struct xkb_context *ctx)
{
if (ctx)
return ctx->user_data;
@ -402,7 +402,7 @@ xkb_get_user_data(struct xkb_context *ctx)
}
XKB_EXPORT void
xkb_set_user_data(struct xkb_context *ctx, void *user_data)
xkb_context_set_user_data(struct xkb_context *ctx, void *user_data)
{
ctx->user_data = user_data;
}

View File

@ -68,12 +68,12 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
const char *fmt, ...);
#define xkb_log_cond_level(ctx, level, ...) do { \
if (xkb_get_log_level(ctx) >= (level)) \
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_get_log_verbosity(ctx) >= (vrb)) \
if (xkb_context_get_log_verbosity(ctx) >= (vrb)) \
xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
} while (0)

View File

@ -311,7 +311,7 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
old = FindMatchingInterp(info, new);
if (old) {
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
bool report = ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9);
@ -425,7 +425,7 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
LEDInfo *old;
enum led_field collide;
struct xkb_context *ctx = info->keymap->ctx;
int verbosity = xkb_get_log_verbosity(ctx);
int verbosity = xkb_context_get_log_verbosity(ctx);
darray_foreach(old, info->leds) {
bool report;

View File

@ -177,7 +177,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
xkb_led_index_t old_idx;
IndicatorNameInfo *old;
bool replace, report;
int verbosity = xkb_get_log_verbosity(info->ctx);
int verbosity = xkb_context_get_log_verbosity(info->ctx);
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
@ -279,7 +279,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name,
{
KeyNameInfo *namei;
xkb_keycode_t old;
int verbosity = xkb_get_log_verbosity(info->ctx);
int verbosity = xkb_context_get_log_verbosity(info->ctx);
if (kc >= darray_size(info->key_names))
darray_resize0(info->key_names, kc + 1);
@ -483,7 +483,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
static void
HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
{
int verbosity = xkb_get_log_verbosity(info->ctx);
int verbosity = xkb_context_get_log_verbosity(info->ctx);
bool report = ((new->file_id == old->file_id && verbosity > 0) ||
verbosity > 9);

View File

@ -399,7 +399,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
xkb_layout_index_t groups_in_both;
enum key_field collide = 0;
bool clobber, report;
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
if (from->merge == MERGE_REPLACE) {
ClearKeyInfo(into);
@ -1669,7 +1669,7 @@ CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
if (!CopySymbolsDef(info, keyi))
info->errorCount++;
if (xkb_get_log_verbosity(keymap->ctx) > 3) {
if (xkb_context_get_log_verbosity(keymap->ctx) > 3) {
xkb_foreach_key(key, keymap) {
if (key->name[0] == '\0')
continue;

View File

@ -252,7 +252,7 @@ static bool
AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new)
{
KeyTypeInfo *old;
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
old = FindMatchingKeyType(info, new->name);
if (old) {

View File

@ -51,7 +51,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);
@ -78,8 +78,8 @@ main(void)
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");
@ -87,15 +87,15 @@ main(void)
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);
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_vrb(ctx, 6, "second verbose 6\n");
xkb_set_log_verbosity(ctx, 0);
xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
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");

View File

@ -92,16 +92,16 @@ static void
benchmark(struct xkb_context *ctx)
{
struct timespec start, stop, elapsed;
enum xkb_log_level old_level = xkb_get_log_level(ctx);
int old_verb = xkb_get_log_verbosity(ctx);
enum xkb_log_level old_level = xkb_context_get_log_level(ctx);
int old_verb = xkb_context_get_log_verbosity(ctx);
int i;
struct xkb_rule_names rmlvo = {
"evdev", "pc105", "us,il", ",", "ctrl:nocaps,grp:menu_toggle",
};
struct xkb_component_names kccgst;
xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
xkb_set_log_verbosity(ctx, 0);
xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
xkb_context_set_log_verbosity(ctx, 0);
clock_gettime(CLOCK_MONOTONIC, &start);
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
@ -113,8 +113,8 @@ benchmark(struct xkb_context *ctx)
}
clock_gettime(CLOCK_MONOTONIC, &stop);
xkb_set_log_level(ctx, old_level);
xkb_set_log_verbosity(ctx, old_verb);
xkb_context_set_log_level(ctx, old_level);
xkb_context_set_log_verbosity(ctx, old_verb);
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;

View File

@ -65,20 +65,20 @@ static void
benchmark(struct xkb_context *context)
{
struct timespec start, stop, elapsed;
enum xkb_log_level old_level = xkb_get_log_level(context);
int old_verb = xkb_get_log_verbosity(context);
enum xkb_log_level old_level = xkb_context_get_log_level(context);
int old_verb = xkb_context_get_log_verbosity(context);
int i;
xkb_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
xkb_set_log_verbosity(context, 0);
xkb_context_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
xkb_context_set_log_verbosity(context, 0);
clock_gettime(CLOCK_MONOTONIC, &start);
for (i = 0; i < BENCHMARK_ITERATIONS; i++)
assert(test_rmlvo_silent(context, "evdev", "evdev", "us", "", ""));
clock_gettime(CLOCK_MONOTONIC, &stop);
xkb_set_log_level(context, old_level);
xkb_set_log_verbosity(context, old_verb);
xkb_context_set_log_level(context, old_level);
xkb_context_set_log_verbosity(context, old_verb);
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;

View File

@ -279,10 +279,10 @@ enum xkb_log_level {
* Passing NULL restores the default function, which logs to stderr.
**/
void
xkb_set_log_fn(struct xkb_context *context,
void (*log_fn)(struct xkb_context *context,
enum xkb_log_level level,
const char *format, va_list args));
xkb_context_set_log_fn(struct xkb_context *context,
void (*log_fn)(struct xkb_context *context,
enum xkb_log_level level,
const char *format, va_list args));
/**
* Sets the current logging level. The value controls which messages
* are logged. The default level is XKB_LOG_LEVEL_ERROR.
@ -291,13 +291,14 @@ xkb_set_log_fn(struct xkb_context *context,
* and may be specified as a level number or name.
*/
void
xkb_set_log_level(struct xkb_context *context, enum xkb_log_level level);
xkb_context_set_log_level(struct xkb_context *context,
enum xkb_log_level level);
/**
* Returns the current logging level.
*/
enum xkb_log_level
xkb_get_log_level(struct xkb_context *context);
xkb_context_get_log_level(struct xkb_context *context);
/**
* Sets the current logging verbosity, a value from 0 to 10.
@ -312,13 +313,13 @@ xkb_get_log_level(struct xkb_context *context);
* or lower.
*/
void
xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity);
xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity);
/**
* Returns the current logging verbosity.
*/
int
xkb_get_log_verbosity(struct xkb_context *ctx);
xkb_context_get_log_verbosity(struct xkb_context *ctx);
/**
* Retrieves stored data pointer from the context. This might be useful
@ -327,13 +328,13 @@ xkb_get_log_verbosity(struct xkb_context *ctx);
* If context is NULL, returns NULL.
**/
void *
xkb_get_user_data(struct xkb_context *context);
xkb_context_get_user_data(struct xkb_context *context);
/**
* Store custom user data in the context.
*/
void
xkb_set_user_data(struct xkb_context *context, void *user_data);
xkb_context_set_user_data(struct xkb_context *context, void *user_data);
/** @} */