logging: Export default log function

This allows users to intercept log messages without fully overriding the
default log handler.
pull/110/head
Andri Yngvason 2023-12-26 11:29:57 +00:00
parent d80b51f650
commit a7f6c50d6d
2 changed files with 5 additions and 5 deletions

View File

@ -235,6 +235,8 @@ void nvnc_set_cursor(struct nvnc*, struct nvnc_fb*, uint16_t width,
uint16_t height, uint16_t hotspot_x, uint16_t hotspot_y, uint16_t height, uint16_t hotspot_x, uint16_t hotspot_y,
bool is_damaged); bool is_damaged);
void nvnc_default_logger(const struct nvnc_log_data* meta, const char* message);
void nvnc_set_log_fn(nvnc_log_fn); void nvnc_set_log_fn(nvnc_log_fn);
void nvnc_set_log_level(enum nvnc_log_level); void nvnc_set_log_level(enum nvnc_log_level);
void nvnc__log(const struct nvnc_log_data*, const char* fmt, ...); void nvnc__log(const struct nvnc_log_data*, const char* fmt, ...);

View File

@ -32,10 +32,7 @@
#define EXPORT __attribute__((visibility("default"))) #define EXPORT __attribute__((visibility("default")))
static void default_logger(const struct nvnc_log_data* meta, static nvnc_log_fn log_fn = nvnc_default_logger;
const char* message);
static nvnc_log_fn log_fn = default_logger;
#ifndef NDEBUG #ifndef NDEBUG
static enum nvnc_log_level log_level = NVNC_LOG_DEBUG; static enum nvnc_log_level log_level = NVNC_LOG_DEBUG;
@ -107,7 +104,8 @@ static void nvnc__vlog(const struct nvnc_log_data* meta, const char* fmt,
abort(); abort();
} }
static void default_logger(const struct nvnc_log_data* meta, EXPORT
void nvnc_default_logger(const struct nvnc_log_data* meta,
const char* message) const char* message)
{ {
const char* level = log_level_to_string(meta->level); const char* level = log_level_to_string(meta->level);