summaryrefslogtreecommitdiff
path: root/libevdev/libevdev.h
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-08-26 13:24:26 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-09-03 16:58:54 +1000
commit55d67a340b058da84b7a5f135192fe126e5cbe0d (patch)
tree1a80b57ac06f491eb00a6fcdd662201385f05f4f /libevdev/libevdev.h
parent37d37cdaea9c010c5f7f0ab878617c8239d14d15 (diff)
downloadlibevdev-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.h')
-rw-r--r--libevdev/libevdev.h40
1 files changed, 36 insertions, 4 deletions
diff --git a/libevdev/libevdev.h b/libevdev/libevdev.h
index 43b768d..36ecdd1 100644
--- a/libevdev/libevdev.h
+++ b/libevdev/libevdev.h
@@ -349,28 +349,58 @@ int libevdev_new_from_fd(int fd, struct libevdev **dev);
*/
void libevdev_free(struct libevdev *dev);
+enum libevdev_log_priority {
+ LIBEVDEV_LOG_ERROR = 10, /** cricitical errors and application bugs */
+ LIBEVDEV_LOG_INFO = 20, /** informational messages */
+ LIBEVDEV_LOG_DEBUG = 30, /** debug information */
+};
+
/**
* Logging function called by library-internal logging.
* This function is expected to treat it's input like printf would.
*
+ * @param priority Log priority of this message
+ * @param data User-supplied data pointer (see libevdev_set_log_function())
+ * @param file libevdev source code file generating this message
+ * @param line libevdev source code line generating this message
+ * @param func libevdev source code function generating this message
* @param format printf-style format string
* @param args List of arguments
*
- * @see libevdev_set_log_handler
+ * @see libevdev_set_log_function
*/
-typedef void (*libevdev_log_func_t)(const char *format, va_list args);
+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);
/**
* Set a printf-style logging handler for library-internal logging. The default
* logging function is a noop.
*
- * @param dev The evdev device
* @param logfunc The logging function for this device. If NULL, the current
* logging function is unset.
+ * @param data User-specific data passed to the log handler.
*
* @note This function may be called before libevdev_set_fd().
*/
-void libevdev_set_log_handler(struct libevdev *dev, libevdev_log_func_t logfunc);
+void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data);
+
+/**
+ * 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.
+ *
+ * @param priority Minimum priority to be printed to the log.
+ *
+ */
+void libevdev_set_log_priority(enum libevdev_log_priority priority);
+
+/**
+ * @return the current log level
+ */
+enum libevdev_log_priority libevdev_get_log_priority(void);
enum libevdev_grab_mode {
@@ -1333,6 +1363,8 @@ int libevdev_get_repeat(struct libevdev *dev, int *delay, int *period);
/* replacement: libevdev_kernel_set_abs_info */
int libevdev_kernel_set_abs_value(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs) LIBEVDEV_DEPRECATED;
+/* replacement: libevdev_set_log_function */
+void libevdev_set_log_handler(struct libevdev *dev, libevdev_log_func_t logfunc) LIBEVDEV_DEPRECATED;
/**************************************/
#ifdef __cplusplus