mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Add the log handlers
And drop the duplicate log handler declarations. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user