Commit 8d7d9792d1e97abf09d6b93605884590e02f346e

Ran Benita 2012-08-28T00:42:59

log: replace "priority" by "level" everywhere Now that we don't use syslog, "level" does sound more commonplace. We should change it while there is still nobody using it. Also leave some space between the integers of the xkb_log_level enum values, if we ever need to shove more in between. 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
diff --git a/src/context.c b/src/context.c
index 6c52d37..b16b803 100644
--- a/src/context.c
+++ b/src/context.c
@@ -176,9 +176,9 @@ xkb_context_unref(struct xkb_context *ctx)
 }
 
 static const char *
-priority_to_prefix(int priority)
+log_level_to_prefix(enum xkb_log_level level)
 {
-    switch (priority) {
+    switch (level) {
     case XKB_LOG_LEVEL_DEBUG:
         return "Debug:";
     case XKB_LOG_LEVEL_INFO:
@@ -188,39 +188,41 @@ priority_to_prefix(int priority)
     case XKB_LOG_LEVEL_ERROR:
         return "Error:";
     case XKB_LOG_LEVEL_CRITICAL:
-        return "Internal error (critical):";
+        return "Critical:";
     default:
         return NULL;
     }
 }
 
 ATTR_PRINTF(3, 0) static void
-default_log_fn(struct xkb_context *ctx, int priority,
+default_log_fn(struct xkb_context *ctx, enum xkb_log_level level,
                const char *fmt, va_list args)
 {
-    const char *prefix = priority_to_prefix(priority);
+    const char *prefix = log_level_to_prefix(level);
 
     if (prefix)
         fprintf(stderr, "%-10s", prefix);
     vfprintf(stderr, fmt, args);
 }
 
-static int
-log_priority(const char *priority) {
+static enum xkb_log_level
+log_level(const char *level) {
     char *endptr;
-    int prio;
+    enum xkb_log_level lvl;
 
     errno = 0;
-    prio = strtol(priority, &endptr, 10);
+    lvl = strtol(level, &endptr, 10);
     if (errno == 0 && (endptr[0] == '\0' || isspace(endptr[0])))
-        return prio;
-    if (strncasecmp(priority, "err", 3) == 0)
+        return lvl;
+    if (istreq_prefix("crit", level))
+        return XKB_LOG_LEVEL_CRITICAL;
+    if (istreq_prefix("err", level))
         return XKB_LOG_LEVEL_ERROR;
-    if (strncasecmp(priority, "warn", 4) == 0)
+    if (istreq_prefix("warn", level))
         return XKB_LOG_LEVEL_WARNING;
-    if (strncasecmp(priority, "info", 4) == 0)
+    if (istreq_prefix("info", level))
         return XKB_LOG_LEVEL_INFO;
-    if (strncasecmp(priority, "debug", 5) == 0)
+    if (istreq_prefix("debug", level) || istreq_prefix("dbg", level))
         return XKB_LOG_LEVEL_DEBUG;
 
     return XKB_LOG_LEVEL_ERROR;
@@ -253,13 +255,13 @@ xkb_context_new(enum xkb_context_flags flags)
 
     ctx->refcnt = 1;
     ctx->log_fn = default_log_fn;
-    ctx->log_priority = XKB_LOG_LEVEL_ERROR;
+    ctx->log_level = XKB_LOG_LEVEL_ERROR;
     ctx->log_verbosity = 0;
 
     /* Environment overwrites defaults. */
     env = getenv("XKB_LOG");
     if (env)
-        xkb_set_log_priority(ctx, log_priority(env));
+        xkb_set_log_level(ctx, log_level(env));
 
     env = getenv("XKB_VERBOSITY");
     if (env)
@@ -307,33 +309,35 @@ xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom)
 }
 
 void
-xkb_log(struct xkb_context *ctx, int priority, const char *fmt, ...)
+xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
+        const char *fmt, ...)
 {
     va_list args;
 
     va_start(args, fmt);
-    ctx->log_fn(ctx, priority, fmt, args);
+    ctx->log_fn(ctx, level, fmt, args);
     va_end(args);
 }
 
 XKB_EXPORT void
 xkb_set_log_fn(struct xkb_context *ctx,
-               void (*log_fn)(struct xkb_context *ctx, int priority,
+               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_priority(struct xkb_context *ctx)
+xkb_get_log_level(struct xkb_context *ctx)
 {
-    return ctx->log_priority;
+    return ctx->log_level;
 }
 
 XKB_EXPORT void
-xkb_set_log_priority(struct xkb_context *ctx, enum xkb_log_level priority)
+xkb_set_log_level(struct xkb_context *ctx, enum xkb_log_level level)
 {
-    ctx->log_priority = priority;
+    ctx->log_level = level;
 }
 
 XKB_EXPORT int
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 2a55baf..3e7fb16 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -98,9 +98,10 @@ typedef uint32_t xkb_atom_t;
 struct xkb_context {
     int refcnt;
 
-    ATTR_PRINTF(3, 0) void (*log_fn)(struct xkb_context *ctx, int priority,
+    ATTR_PRINTF(3, 0) void (*log_fn)(struct xkb_context *ctx,
+                                     enum xkb_log_level level,
                                      const char *fmt, va_list args);
-    enum xkb_log_level log_priority;
+    enum xkb_log_level log_level;
     int log_verbosity;
     void *user_data;
 
@@ -464,19 +465,18 @@ bool
 xkb_keysym_is_keypad(xkb_keysym_t keysym);
 
 ATTR_PRINTF(3, 4) void
-xkb_log(struct xkb_context *ctx, int priority, const char *fmt, ...);
+xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
+        const char *fmt, ...);
 
-#define xkb_log_cond(ctx, prio, ...) \
-    do { \
-        if (xkb_get_log_priority(ctx) >= (prio)) \
-            xkb_log((ctx), (prio), __VA_ARGS__); \
-    } while (0)
+#define xkb_log_cond_level(ctx, level, ...) do { \
+    if (xkb_get_log_level(ctx) >= (level)) \
+    xkb_log((ctx), (level), __VA_ARGS__); \
+} while (0)
 
-#define xkb_log_cond_lvl(ctx, prio, lvl, ...) \
-    do { \
-        if (xkb_get_log_verbosity(ctx) >= (lvl)) \
-            xkb_log_cond((ctx), (prio), __VA_ARGS__); \
-    } while (0)
+#define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \
+    if (xkb_get_log_verbosity(ctx) >= (vrb)) \
+    xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
+} while (0)
 
 /*
  * The format is not part of the argument list in order to avoid the
@@ -485,16 +485,16 @@ xkb_log(struct xkb_context *ctx, int priority, const char *fmt, ...);
  * result in an error, though.
  */
 #define log_dbg(ctx, ...) \
-    xkb_log_cond((ctx), XKB_LOG_LEVEL_DEBUG, __VA_ARGS__)
+    xkb_log_cond_level((ctx), XKB_LOG_LEVEL_DEBUG, __VA_ARGS__)
 #define log_info(ctx, ...) \
-    xkb_log_cond((ctx), XKB_LOG_LEVEL_INFO, __VA_ARGS__)
+    xkb_log_cond_level((ctx), XKB_LOG_LEVEL_INFO, __VA_ARGS__)
 #define log_warn(ctx, ...) \
-    xkb_log_cond((ctx), XKB_LOG_LEVEL_WARNING, __VA_ARGS__)
+    xkb_log_cond_level((ctx), XKB_LOG_LEVEL_WARNING, __VA_ARGS__)
 #define log_err(ctx, ...) \
-    xkb_log_cond((ctx), XKB_LOG_LEVEL_ERROR, __VA_ARGS__)
+    xkb_log_cond_level((ctx), XKB_LOG_LEVEL_ERROR, __VA_ARGS__)
 #define log_wsgo(ctx, ...) \
-    xkb_log_cond((ctx), XKB_LOG_LEVEL_CRITICAL, __VA_ARGS__)
-#define log_lvl(ctx, lvl, ...) \
-    xkb_log_cond_lvl((ctx), XKB_LOG_LEVEL_WARNING, (lvl), __VA_ARGS__)
+    xkb_log_cond_level((ctx), XKB_LOG_LEVEL_CRITICAL, __VA_ARGS__)
+#define log_vrb(ctx, vrb, ...) \
+    xkb_log_cond_verbosity((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
 
 #endif /* XKB_PRIV_H */
diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c
index 3599602..692da56 100644
--- a/src/xkbcomp/include.c
+++ b/src/xkbcomp/include.c
@@ -250,7 +250,7 @@ ProcessIncludeFile(struct xkb_context *ctx,
         }
     }
     else if (rtrn->common.next) {
-        log_lvl(ctx, 5,
+        log_vrb(ctx, 5,
                 "No map in include statement, but \"%s\" contains several; "
                 "Using first defined map, \"%s\"\n",
                 stmt->file, rtrn->name);
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 872f671..49d07a6 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -755,7 +755,7 @@ ApplyAliases(KeyNamesInfo *info, struct xkb_keymap *keymap)
         /* Check that ->real is a key. */
         key = FindNamedKey(keymap, alias->real, false, 0);
         if (!key) {
-            log_lvl(info->ctx, 5,
+            log_vrb(info->ctx, 5,
                     "Attempt to alias %s to non-existent key %s; Ignored\n",
                     LongKeyNameText(alias->alias),
                     LongKeyNameText(alias->real));
@@ -765,7 +765,7 @@ ApplyAliases(KeyNamesInfo *info, struct xkb_keymap *keymap)
         /* Check that ->alias is not a key. */
         key = FindNamedKey(keymap, alias->alias, false, 0);
         if (key) {
-            log_lvl(info->ctx, 5,
+            log_vrb(info->ctx, 5,
                     "Attempt to create alias with the name of a real key; "
                     "Alias \"%s = %s\" ignored\n",
                     LongKeyNameText(alias->alias),
diff --git a/src/xkbcomp/scanner.l b/src/xkbcomp/scanner.l
index 6dfa28b..b29b711 100644
--- a/src/xkbcomp/scanner.l
+++ b/src/xkbcomp/scanner.l
@@ -242,7 +242,7 @@ CheckDefaultMap(struct xkb_context *ctx, XkbFile *maps, const char *fileName)
             continue;
         }
 
-        log_lvl(ctx, 3,
+        log_vrb(ctx, 3,
                 "Multiple default components in %s; "
                 "Using %s, ignoring %s\n",
                 (fileName ? fileName : "(unknown)"),
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 09def70..b245201 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1033,7 +1033,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         const char *str;
 
         if (!ExprResolveString(ctx, value, &str))
-            log_lvl(info->keymap->ctx, 1,
+            log_vrb(info->keymap->ctx, 1,
                     "The type field of a key symbol map must be a string; "
                     "Ignoring illegal type definition\n");
 
@@ -1187,7 +1187,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
     const char *name;
 
     if (!arrayNdx) {
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "You must specify an index when specifying a group name; "
                 "Group name definition without array subscript ignored\n");
         return false;
@@ -1724,7 +1724,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
     key = FindNamedKey(keymap, keyi->name, useAlias, start_from);
     if (!key) {
         if (start_from == 0)
-            log_lvl(info->keymap->ctx, 5,
+            log_vrb(info->keymap->ctx, 5,
                     "Key %s not found in keycodes; Symbols ignored\n",
                     LongKeyNameText(keyi->name));
         return false;
@@ -1749,7 +1749,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
                                        darray_mem(keyi->syms[i], 0),
                                        &keyi->types[i], &autoType)) { }
             else
-                log_lvl(info->keymap->ctx, 5,
+                log_vrb(info->keymap->ctx, 5,
                         "No automatic type for %d symbols; "
                         "Using %s for the %s key (keycode %d)\n",
                         keyi->numLevels[i],
@@ -1761,7 +1761,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
                 key->explicit |= (1 << i);
         }
         else {
-            log_lvl(info->keymap->ctx, 3,
+            log_vrb(info->keymap->ctx, 3,
                     "Type \"%s\" is not defined; "
                     "Using default type for the %s key (keycode %d)\n",
                     xkb_atom_text(keymap->ctx, keyi->types[i]),
@@ -1776,7 +1776,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
         /* if the type specifies fewer levels than the key has, shrink the key */
         type = &keymap->types[types[i]];
         if (type->num_levels < keyi->numLevels[i]) {
-            log_lvl(info->keymap->ctx, 1,
+            log_vrb(info->keymap->ctx, 1,
                     "Type \"%s\" has %d levels, but %s has %d symbols; "
                     "Ignoring extra symbols\n",
                     xkb_atom_text(keymap->ctx, type->name),
@@ -1875,7 +1875,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
     if (!entry->haveSymbol) {
         key = FindNamedKey(keymap, entry->u.keyName, true, 0);
         if (!key) {
-            log_lvl(info->keymap->ctx, 5,
+            log_vrb(info->keymap->ctx, 5,
                     "Key %s not found in keycodes; "
                     "Modifier map entry for %s not updated\n",
                     LongKeyNameText(entry->u.keyName),
@@ -1886,7 +1886,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
     else {
         key = FindKeyForSymbol(keymap, entry->u.keySym);
         if (!key) {
-            log_lvl(info->keymap->ctx, 5,
+            log_vrb(info->keymap->ctx, 5,
                     "Key \"%s\" not found in symbol map; "
                     "Modifier map entry for %s not updated\n",
                     KeysymText(entry->u.keySym),
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index d5071d4..fa6da56 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -276,7 +276,7 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new)
         }
 
         if (old->file_id == new->file_id)
-            log_lvl(info->keymap->ctx, 4,
+            log_vrb(info->keymap->ctx, 4,
                     "Multiple definitions of the %s key type; "
                     "Later definition ignored\n",
                     xkb_atom_text(info->keymap->ctx, new->name));
@@ -422,7 +422,7 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type,
                      (clobber ? old->level : new->level) + 1);
         }
         else {
-            log_lvl(info->keymap->ctx, 10,
+            log_vrb(info->keymap->ctx, 10,
                     "Multiple occurences of map[%s]= %d in %s; Ignored\n",
                     MapEntryTxt(info, new), new->level + 1,
                     TypeTxt(info, type));
@@ -458,7 +458,7 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
         return ReportTypeBadType(info, type, "map entry", "modifier mask");
 
     if (entry.mods.mods & (~type->mods)) {
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "Map entry for unused modifiers in %s; "
                 "Using %s instead of %s\n",
                 TypeTxt(info, type),
@@ -500,7 +500,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
 
         /* Map exists with same preserve; do nothing. */
         if (entry->preserve.mods == preserve_mods) {
-            log_lvl(info->keymap->ctx, 10,
+            log_vrb(info->keymap->ctx, 10,
                     "Identical definitions for preserve[%s] in %s; "
                     "Ignored\n",
                     VModMaskText(info->keymap, mods),
@@ -509,7 +509,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
         }
 
         /* Map exists with different preserve; latter wins. */
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "Multiple definitions for preserve[%s] in %s; "
                 "Using %s, ignoring %s\n",
                 VModMaskText(info->keymap, mods),
@@ -553,7 +553,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
         mods &= type->mods;
         after = VModMaskText(info->keymap, mods);
 
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "Preserve for modifiers not used by the %s type; "
                 "Index %s converted to %s\n",
                 TypeTxt(info, type), before, after);
@@ -575,7 +575,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
         preserve_mods &= mods;
         after = VModMaskText(info->keymap, preserve_mods);
 
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "Illegal value for preserve[%s] in type %s; "
                 "Converted %s to %s\n",
                 VModMaskText(info->keymap, mods),
@@ -599,7 +599,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
 
     /* Same level, same name. */
     if (darray_item(type->level_names, level) == name) {
-        log_lvl(info->keymap->ctx, 10,
+        log_vrb(info->keymap->ctx, 10,
                 "Duplicate names for level %d of key type %s; Ignored\n",
                 level + 1, TypeTxt(info, type));
         return true;
@@ -611,7 +611,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
         old = xkb_atom_text(info->keymap->ctx,
                             darray_item(type->level_names, level));
         new = xkb_atom_text(info->keymap->ctx, name);
-        log_lvl(info->keymap->ctx, 1,
+        log_vrb(info->keymap->ctx, 1,
                 "Multiple names for level %d of key type %s; "
                 "Using %s, ignoring %s\n",
                 level + 1, TypeTxt(info, type),
diff --git a/test/common.c b/test/common.c
index 2d49824..351276e 100644
--- a/test/common.c
+++ b/test/common.c
@@ -101,7 +101,7 @@ test_get_context(void)
 
     xkb_context_include_path_append(ctx, test_get_path(""));
 
-    xkb_set_log_priority(ctx, XKB_LOG_LEVEL_DEBUG);
+    xkb_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
     xkb_set_log_verbosity(ctx, 101);
 
     return ctx;
diff --git a/test/log.c b/test/log.c
index f3e7cee..6f40ec0 100644
--- a/test/log.c
+++ b/test/log.c
@@ -32,9 +32,11 @@
 #pragma GCC diagnostic ignored "-Wmissing-format-attribute"
 
 static const char *
-priority_to_string(int priority)
+log_level_to_string(enum xkb_log_level level)
 {
-    switch (priority) {
+    switch (level) {
+    case XKB_LOG_LEVEL_CRITICAL:
+        return "critical";
     case XKB_LOG_LEVEL_ERROR:
         return "error";
     case XKB_LOG_LEVEL_WARNING:
@@ -49,7 +51,8 @@ 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;
@@ -59,7 +62,7 @@ log_fn(struct xkb_context *ctx, int priority, const char *fmt, va_list args)
     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,6 +76,7 @@ main(void)
     int ret;
 
     ret = setenv("XKB_LOG", "warn", 1);
+    assert(ret == 0);
     ret = setenv("XKB_VERBOSITY", "5", 1);
     assert(ret == 0);
     ctx = xkb_context_new(0);
@@ -86,22 +90,22 @@ main(void)
     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, XKB_LOG_LEVEL_DEBUG);
+    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_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, XKB_LOG_LEVEL_CRITICAL);
+    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_lvl(ctx, 0, "third verbose 0\n");
+    log_vrb(ctx, 0, "third verbose 0\n");
 
     printf("%s", log_string.item);
 
diff --git a/test/rulescomp.c b/test/rulescomp.c
index fe17b8d..0d40761 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -70,11 +70,11 @@ static void
 benchmark(struct xkb_context *context)
 {
     struct timespec start, stop, elapsed;
-    enum xkb_log_level old_prio = xkb_get_log_priority(context);
+    enum xkb_log_level old_level = xkb_get_log_level(context);
     int old_verb = xkb_get_log_verbosity(context);
     int i;
 
-    xkb_set_log_priority(context, XKB_LOG_LEVEL_CRITICAL);
+    xkb_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
     xkb_set_log_verbosity(context, 0);
 
     clock_gettime(CLOCK_MONOTONIC, &start);
@@ -82,7 +82,7 @@ benchmark(struct xkb_context *context)
         assert(test_rmlvo_silent(context, "evdev", "evdev", "us", "", ""));
     clock_gettime(CLOCK_MONOTONIC, &stop);
 
-    xkb_set_log_priority(context, old_prio);
+    xkb_set_log_level(context, old_level);
     xkb_set_log_verbosity(context, old_verb);
 
     elapsed.tv_sec = stop.tv_sec - start.tv_sec;
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index 9fc6c7b..6333f97 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -258,15 +258,15 @@ xkb_context_unref(struct xkb_context *context);
 
 enum xkb_log_level {
     /** Log critical internal errors only */
-    XKB_LOG_LEVEL_CRITICAL = 0,
+    XKB_LOG_LEVEL_CRITICAL = 10,
     /** Log all errors */
-    XKB_LOG_LEVEL_ERROR = 1,
+    XKB_LOG_LEVEL_ERROR = 20,
     /** Log warnings and errors */
-    XKB_LOG_LEVEL_WARNING = 2,
+    XKB_LOG_LEVEL_WARNING = 30,
     /** Log information, warnings, and errors */
-    XKB_LOG_LEVEL_INFO = 3,
+    XKB_LOG_LEVEL_INFO = 40,
     /** Log all the things */
-    XKB_LOG_LEVEL_DEBUG = 4,
+    XKB_LOG_LEVEL_DEBUG = 50,
 };
 
 /**
@@ -275,23 +275,24 @@ enum xkb_log_level {
  **/
 void
 xkb_set_log_fn(struct xkb_context *context,
-               void (*log_fn)(struct xkb_context *context, int priority,
+               void (*log_fn)(struct xkb_context *context,
+                              enum xkb_log_level level,
                               const char *format, va_list args));
 /**
- * Sets the current logging priority. The value controls which messages
- * are logged.  The default priority is LOG_ERR.
+ * Sets the current logging level.  The value controls which messages
+ * are logged.  The default level is XKB_LOG_LEVEL_ERROR.
  *
  * The environment variable XKB_LOG, if set, overrides the default value
- * and may be specified as a priority number or name.
+ * and may be specified as a level number or name.
  */
 void
-xkb_set_log_priority(struct xkb_context *context, enum xkb_log_level priority);
+xkb_set_log_level(struct xkb_context *context, enum xkb_log_level level);
 
 /**
- * Returns the current logging priority.
+ * Returns the current logging level.
  */
 enum xkb_log_level
-xkb_get_log_priority(struct xkb_context *context);
+xkb_get_log_level(struct xkb_context *context);
 
 /**
  * Sets the current logging verbosity, a value from 0 to 10.
@@ -302,7 +303,7 @@ xkb_get_log_priority(struct xkb_context *context);
  * The environment variable XKB_VERBOSITY, if set, overrdies the default
  * value.
  *
- * Note that most verbose messages are of priority XKB_LOG_LEVEL_WARNING
+ * Note that most verbose messages are of level XKB_LOG_LEVEL_WARNING
  * or lower.
  */
 void