diff options
author | David Robillard <d@drobilla.net> | 2016-07-30 19:08:26 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-07-31 14:24:20 -0400 |
commit | 7a5037a1508e3b84b2f742cda09a044451705d25 (patch) | |
tree | cb23094fde71b7737675280bc870ac109942fa22 /lv2/lv2plug.in/ns/ext/log/logger.h | |
parent | fdeaa14f4078d9eab71fcf38d69010936afd77f7 (diff) | |
download | lv2-7a5037a1508e3b84b2f742cda09a044451705d25.tar.xz |
Add lv2_log_logger_set_map()
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/log/logger.h')
-rw-r--r-- | lv2/lv2plug.in/ns/ext/log/logger.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lv2/lv2plug.in/ns/ext/log/logger.h b/lv2/lv2plug.in/ns/ext/log/logger.h index 62de1ce..0ef28b8 100644 --- a/lv2/lv2plug.in/ns/ext/log/logger.h +++ b/lv2/lv2plug.in/ns/ext/log/logger.h @@ -50,6 +50,25 @@ typedef struct { } LV2_Log_Logger; /** + Set `map` as the URI map for `logger`. + + This affects the message type URIDs (Error, Warning, etc) which are passed + to the log's print functions. +*/ +static inline void +lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map) +{ + if (map) { + logger->Error = map->map(map->handle, LV2_LOG__Error); + logger->Note = map->map(map->handle, LV2_LOG__Note); + logger->Trace = map->map(map->handle, LV2_LOG__Trace); + logger->Warning = map->map(map->handle, LV2_LOG__Warning); + } else { + logger->Error = logger->Note = logger->Trace = logger->Warning = 0; + } +} + +/** Initialise `logger`. URIs will be mapped using `map` and stored, a reference to `map` itself is @@ -61,14 +80,8 @@ lv2_log_logger_init(LV2_Log_Logger* logger, LV2_URID_Map* map, LV2_Log_Log* log) { - memset(logger, 0, sizeof(LV2_Log_Logger)); logger->log = log; - if (map) { - logger->Error = map->map(map->handle, LV2_LOG__Error); - logger->Note = map->map(map->handle, LV2_LOG__Note); - logger->Trace = map->map(map->handle, LV2_LOG__Trace); - logger->Warning = map->map(map->handle, LV2_LOG__Warning); - } + lv2_log_logger_set_map(logger, map); } /** |