libxkbcommon: Logging Handling

libxkbcommon 1.13.2 Library implementing the XKB specification for parsing keyboard descriptions and handling keyboard state

Loading...
Searching...
No Matches
Enumerations | Functions
Logging Handling

## Enumerations
enum | xkb_log_level { XKB_LOG_LEVEL_CRITICAL = 10 , XKB_LOG_LEVEL_ERROR = 20 , XKB_LOG_LEVEL_WARNING = 30 , XKB_LOG_LEVEL_INFO = 40 , XKB_LOG_LEVEL_DEBUG = 50 }

## Functions
XKB_EXPORT void | xkb_context::xkb_context_set_log_level (struct xkb_context *context, enum xkb_log_level level)
XKB_EXPORT enum xkb_log_level | xkb_context::xkb_context_get_log_level (struct xkb_context *context)
XKB_EXPORT void | xkb_context::xkb_context_set_log_verbosity (struct xkb_context *context, int verbosity)
XKB_EXPORT int | xkb_context::xkb_context_get_log_verbosity (struct xkb_context *context)
XKB_EXPORT void | xkb_context::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))

## Detailed Description

Manipulating how logging from this library is handled.

## Enumeration Type Documentation

## ◆ xkb_log_level

enum xkb_log_level

Specifies a logging level.

Enumerator
XKB_LOG_LEVEL_CRITICAL | Log critical internal errors only.
XKB_LOG_LEVEL_ERROR | Log all errors.
XKB_LOG_LEVEL_WARNING | Log warnings and errors.
XKB_LOG_LEVEL_INFO | Log information, warnings, and errors.
XKB_LOG_LEVEL_DEBUG | Log everything.

## Function Documentation

## ◆ xkb_context_set_log_level()

XKB_EXPORT void xkb_context_set_log_level | ( | struct xkb_context * | context,
|  | enum xkb_log_level | level )

Set the current logging level.

Parameters

  context | The context in which to set the logging level.
  level | The logging level to use. Only messages from this level and below will be logged.

The default level is XKB_LOG_LEVEL_ERROR. The environment variable XKB_LOG_LEVEL, if set in the time the context was created, overrides the default value. It may be specified as a level number or name.

## ◆ xkb_context_set_log_verbosity()

XKB_EXPORT void xkb_context_set_log_verbosity | ( | struct xkb_context * | context,
|  | int | verbosity )

Sets the current logging verbosity.

The library can generate a number of warnings which are not helpful to ordinary users of the library. The verbosity may be increased if more information is desired (e.g. when developing a new keymap).

The default verbosity is 0. The environment variable XKB_LOG_VERBOSITY, if set in the time the context was created, overrides the default value.

Parameters

  context | The context in which to use the set verbosity.
  verbosity | The verbosity to use. Currently used values are 1 to 10, higher values being more verbose. 0 would result in no verbose messages being logged.

Most verbose messages are of level XKB_LOG_LEVEL_WARNING or lower.

## ◆ xkb_context_set_log_fn()

XKB_EXPORT void 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) )

Set a custom function to handle logging messages.

Parameters

  context | The context in which to use the set logging function.
  log_fn | The function that will be called for logging messages. Passing NULL restores the default function, which logs to stderr.

By default, log messages from this library are printed to stderr. This function allows you to replace the default behavior with a custom handler. The handler is only called with messages which match the current logging level and verbosity settings for the context. level is the logging level of the message. format and args are the same as in the vprintf(3) function.

You may use xkb_context::xkb_context_set_user_data() on the context, and then call xkb_context::xkb_context_get_user_data() from within the logging function to provide it with additional private context.