From 388ded0067a6ab447c781c4cebdae1cdab68866e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Aug 2015 11:29:00 +1000 Subject: [PATCH] Add the log handlers And drop the duplicate log handler declarations. Signed-off-by: Peter Hutterer --- src/libratbag.c | 21 +++++++++++++++ src/libratbag.h | 66 ++++++++++++++--------------------------------- src/libratbag.sym | 3 +++ 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/libratbag.c b/src/libratbag.c index c880e4da..2cf84b88 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -75,6 +75,27 @@ log_msg(struct libratbag *libratbag, va_end(args); } +LIBRATBAG_EXPORT void +libratbag_log_set_priority(struct libratbag *libratbag, + enum libratbag_log_priority priority) +{ + libratbag->log_priority = priority; +} + +LIBRATBAG_EXPORT enum libratbag_log_priority +libratbag_log_get_priority(const struct libratbag *libratbag) +{ + return libratbag->log_priority; +} + +LIBRATBAG_EXPORT void +libratbag_log_set_handler(struct libratbag *libratbag, + libratbag_log_handler log_handler) +{ + libratbag->log_handler = log_handler; +} + + static inline struct udev_device * udev_device_from_devnode(struct libratbag *libratbag, struct ratbag *ratbag, diff --git a/src/libratbag.h b/src/libratbag.h index e60c296a..eaa76f4c 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -37,6 +37,8 @@ extern "C" { #define LIBRATBAG_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) /** + * @ingroup base + * * Log priority for internal logging messages. */ enum libratbag_log_priority { @@ -693,17 +695,6 @@ ratbag_ref(struct ratbag *ratbag); struct ratbag * ratbag_unref(struct ratbag *ratbag); -/** - * @ingroup base - * - * Log priority for internal logging messages. - */ -enum ratbag_log_priority { - RATBAG_LOG_PRIORITY_DEBUG = 10, - RATBAG_LOG_PRIORITY_INFO = 20, - RATBAG_LOG_PRIORITY_ERROR = 30, -}; - /** * @ingroup base * @@ -711,17 +702,17 @@ enum ratbag_log_priority { * equal to or higher than the argument will be printed to the context's * log handler. * - * The default log priority is @ref RATBAG_LOG_PRIORITY_ERROR. + * The default log priority is @ref LIBRATBAG_LOG_PRIORITY_ERROR. * - * @param ratbag A previously initialized ratbag context + * @param libratbag A previously initialized ratbag context * @param priority The minimum priority of log messages to print. * - * @see ratbag_log_set_handler - * @see ratbag_log_get_priority + * @see libratbag_log_set_handler + * @see libratbag_log_get_priority */ void -ratbag_log_set_priority(struct ratbag *ratbag, - enum ratbag_log_priority priority); +libratbag_log_set_priority(struct libratbag *libratbag, + enum libratbag_log_priority priority); /** * @ingroup base @@ -729,35 +720,16 @@ ratbag_log_set_priority(struct ratbag *ratbag, * Get the context's log priority. Messages with priorities equal to or * higher than the argument will be printed to the current log handler. * - * The default log priority is @ref RATBAG_LOG_PRIORITY_ERROR. + * The default log priority is @ref LIBRATBAG_LOG_PRIORITY_ERROR. * - * @param ratbag A previously initialized ratbag context + * @param libratbag A previously initialized libratbag context * @return The minimum priority of log messages to print. * - * @see ratbag_log_set_handler - * @see ratbag_log_set_priority + * @see libratbag_log_set_handler + * @see libratbag_log_set_priority */ -enum ratbag_log_priority -ratbag_log_get_priority(const struct ratbag *ratbag); - -/** - * @ingroup base - * - * Log handler type for custom logging. - * - * @param ratbag The ratbag context - * @param priority The priority of the current message - * @param format Message format in printf-style - * @param args Message arguments - * - * @see ratbag_log_set_priority - * @see ratbag_log_get_priority - * @see ratbag_log_set_handler - */ -typedef void (*ratbag_log_handler)(struct ratbag *ratbag, - enum ratbag_log_priority priority, - const char *format, va_list args) - LIBRATBAG_ATTRIBUTE_PRINTF(3, 0); +enum libratbag_log_priority +libratbag_log_get_priority(const struct libratbag *libratbag); /** * @ingroup base @@ -768,15 +740,15 @@ typedef void (*ratbag_log_handler)(struct ratbag *ratbag, * * The default log handler prints to stderr. * - * @param ratbag A previously initialized ratbag context + * @param libratbag A previously initialized libratbag context * @param log_handler The log handler for library messages. * - * @see ratbag_log_set_priority - * @see ratbag_log_get_priority + * @see libratbag_log_set_priority + * @see libratbag_log_get_priority */ void -ratbag_log_set_handler(struct ratbag *ratbag, - ratbag_log_handler log_handler); +libratbag_log_set_handler(struct libratbag *libratbag, + libratbag_log_handler log_handler); #ifdef __cplusplus } diff --git a/src/libratbag.sym b/src/libratbag.sym index 357bef9b..1cf0dacb 100644 --- a/src/libratbag.sym +++ b/src/libratbag.sym @@ -5,6 +5,9 @@ global: libratbag_create_context; libratbag_ref; libratbag_unref; + libratbag_log_get_priority; + libratbag_log_set_handler; + libratbag_log_set_priority; ratbag_button_ref; ratbag_button_unref; ratbag_profile_get_button_by_index;