From 7a5037a1508e3b84b2f742cda09a044451705d25 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 30 Jul 2016 19:08:26 -0400 Subject: Add lv2_log_logger_set_map() --- lv2/lv2plug.in/ns/ext/log/logger.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'lv2/lv2plug.in/ns/ext/log/logger.h') 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 @@ -49,6 +49,25 @@ typedef struct { LV2_URID Warning; } 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`. @@ -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); } /** -- cgit v1.2.1