diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-26 13:24:26 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-09-03 16:58:54 +1000 |
| commit | 55d67a340b058da84b7a5f135192fe126e5cbe0d (patch) | |
| tree | 1a80b57ac06f491eb00a6fcdd662201385f05f4f /libevdev/libevdev-int.h | |
| parent | 37d37cdaea9c010c5f7f0ab878617c8239d14d15 (diff) | |
| download | libevdev-55d67a340b058da84b7a5f135192fe126e5cbe0d.tar.gz | |
Drop per-device logging function, use per-library one instead
There's no need to have separate logging function for each device created.
More likely, libevdev will be hooked up once into the logging system and
expected to deal with it.
Plus, this allows us to log from the uinput code where we don't
have the context anyway.
Requires a rename to libevdev_set_log_function to avoid ABI breaks, and
while we're breaking the ABI make the logging function more sophisticated
to log line, number, etc.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'libevdev/libevdev-int.h')
| -rw-r--r-- | libevdev/libevdev-int.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/libevdev/libevdev-int.h b/libevdev/libevdev-int.h index dd38cc8..e77db32 100644 --- a/libevdev/libevdev-int.h +++ b/libevdev/libevdev-int.h @@ -38,6 +38,7 @@ #define ABS_MT_MAX ABS_MT_TOOL_Y #define ABS_MT_CNT (ABS_MT_MAX - ABS_MT_MIN + 1) #define LIBEVDEV_EXPORT __attribute__((visibility("default"))) +#define LIBEVDEV_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args))) #undef min #undef max @@ -71,8 +72,6 @@ enum SyncState { struct libevdev { int fd; - libevdev_log_func_t log; - char *name; char *phys; char *uniq; @@ -109,6 +108,30 @@ struct libevdev { struct timeval last_event_time; }; +struct logdata { + enum libevdev_log_priority priority; /** minimum logging priority */ + libevdev_log_func_t handler; /** handler function */ + void *userdata; /** user-defined data pointer */ +}; +extern struct logdata log_data; + +#define log_msg_cond(priority, ...) \ + do { \ + if (libevdev_get_log_priority() >= priority) \ + log_msg(priority, log_data.userdata, __FILE__, __LINE__, __func__, __VA_ARGS__); \ + } while(0) + +#define log_error(...) log_msg_cond(LIBEVDEV_LOG_ERROR, __VA_ARGS__) +#define log_info(...) log_msg_cond(LIBEVDEV_LOG_INFO, __VA_ARGS__) +#define log_dbg(...) log_msg_cond(LIBEVDEV_LOG_DEBUG, __VA_ARGS__) +#define log_bug(...) log_msg_cond(LIBEVDEV_LOG_ERROR, "BUG: "__VA_ARGS__) + +extern void +log_msg(enum libevdev_log_priority priority, + void *data, + const char *file, int line, const char *func, + const char *format, ...) LIBEVDEV_PRINTF(6, 7); + /** * @return a pointer to the next element in the queue, or NULL if the queue * is full. |
