Loading...
Searching...
No Matches
Library logging facilities

libevdev provides two methods of logging library-internal messages. More...

Typedefs

typedef void(* libevdev_log_func_t) (enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args)
 Logging function called by library-internal logging.
 
typedef void(* libevdev_device_log_func_t) (const struct libevdev *dev, enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args)
 Logging function called by library-internal logging for a specific libevdev context.
 

Enumerations

enum  libevdev_log_priority { LIBEVDEV_LOG_ERROR , LIBEVDEV_LOG_INFO , LIBEVDEV_LOG_DEBUG }
 

Functions

void libevdev_set_log_function (libevdev_log_func_t logfunc, void *data)
 Set a printf-style logging handler for library-internal logging.
 
void libevdev_set_log_priority (enum libevdev_log_priority priority)
 Define the minimum level to be printed to the log handler.
 
enum libevdev_log_priority libevdev_get_log_priority (void)
 Return the current log priority level.
 
void libevdev_set_device_log_function (struct libevdev *dev, libevdev_device_log_func_t logfunc, enum libevdev_log_priority priority, void *data)
 Set a printf-style logging handler for library-internal logging for this device context.
 

Detailed Description

libevdev provides two methods of logging library-internal messages.

The old method is to provide a global log handler in libevdev_set_log_function(). The new method is to provide a per-context log handler in libevdev_set_device_log_function(). Developers are encouraged to use the per-context logging facilities over the global log handler as it provides access to the libevdev instance that caused a message, and is more flexible when libevdev is used from within a shared library.

If a caller sets both the global log handler and a per-context log handler, each device with a per-context log handler will only invoke that log handler.

Note
To set a context-specific log handler, a context is needed. Thus developers are discouraged from using libevdev_new_from_fd() as important messages from the device initialization process may get lost.
A context-specific handler cannot be used for libevdev's uinput devices. uinput device creation must use the global log handler.

Typedef Documentation

◆ libevdev_device_log_func_t

typedef void(* libevdev_device_log_func_t) (const struct libevdev *dev, enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args)

Logging function called by library-internal logging for a specific libevdev context.

This function is expected to treat its input like printf would.

Parameters
devThe evdev device
priorityLog priority of this message
dataUser-supplied data pointer (see libevdev_set_log_function())
filelibevdev source code file generating this message
linelibevdev source code line generating this message
funclibevdev source code function generating this message
formatprintf-style format string
argsList of arguments
See also
libevdev_set_log_function
Since
1.3

◆ libevdev_log_func_t

typedef void(* libevdev_log_func_t) (enum libevdev_log_priority priority, void *data, const char *file, int line, const char *func, const char *format, va_list args)

Logging function called by library-internal logging.

This function is expected to treat its input like printf would.

Parameters
priorityLog priority of this message
dataUser-supplied data pointer (see libevdev_set_log_function())
filelibevdev source code file generating this message
linelibevdev source code line generating this message
funclibevdev source code function generating this message
formatprintf-style format string
argsList of arguments
See also
libevdev_set_log_function

Enumeration Type Documentation

◆ libevdev_log_priority

Enumerator
LIBEVDEV_LOG_ERROR 

critical errors and application bugs

LIBEVDEV_LOG_INFO 

informational messages

LIBEVDEV_LOG_DEBUG 

debug information

Function Documentation

◆ libevdev_get_log_priority()

enum libevdev_log_priority libevdev_get_log_priority ( void  )

Return the current log priority level.

Messages higher than this level are printed, others are discarded. This is a global setting.

Returns
the current log level
Deprecated:
Use per-context logging instead, see libevdev_set_device_log_function().

◆ libevdev_set_device_log_function()

void libevdev_set_device_log_function ( struct libevdev *  dev,
libevdev_device_log_func_t  logfunc,
enum libevdev_log_priority  priority,
void *  data 
)

Set a printf-style logging handler for library-internal logging for this device context.

The default logging function is NULL, i.e. the global log handler is invoked. If a context-specific log handler is set, the global log handler is not invoked for this device.

Note
This log function applies for this device context only, even if another context exists for the same fd.
Parameters
devThe evdev device
logfuncThe logging function for this device. If NULL, the current logging function is unset and logging falls back to the global log handler, if any.
priorityMinimum priority to be printed to the log.
dataUser-specific data passed to the log handler.
Note
This function may be called before libevdev_set_fd().
Since
1.3

◆ libevdev_set_log_function()

void libevdev_set_log_function ( libevdev_log_func_t  logfunc,
void *  data 
)

Set a printf-style logging handler for library-internal logging.

The default logging function is to stdout.

Note
The global log handler is only called if no context-specific log handler has been set with libevdev_set_device_log_function().
Parameters
logfuncThe logging function for this device. If NULL, the current logging function is unset and no logging is performed.
dataUser-specific data passed to the log handler.
Note
This function may be called before libevdev_set_fd().
Deprecated:
Use per-context logging instead, see libevdev_set_device_log_function().

◆ libevdev_set_log_priority()

void libevdev_set_log_priority ( enum libevdev_log_priority  priority)

Define the minimum level to be printed to the log handler.

Messages higher than this level are printed, others are discarded. This is a global setting and applies to any future logging messages.

Parameters
priorityMinimum priority to be printed to the log.
Deprecated:
Use per-context logging instead, see libevdev_set_device_log_function().