diff options
author | David Robillard <d@drobilla.net> | 2022-05-30 22:14:08 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:50:35 -0400 |
commit | 54cb5482c0ad254551e4b958e1f20db22ef522e3 (patch) | |
tree | 81ef0af7511f1a0355d4f080dcb01826aa864a6a | |
parent | 237bea29faafa801cec1af034458c5a85e4d134f (diff) | |
download | jalv-54cb5482c0ad254551e4b958e1f20db22ef522e3.tar.gz jalv-54cb5482c0ad254551e4b958e1f20db22ef522e3.tar.bz2 jalv-54cb5482c0ad254551e4b958e1f20db22ef522e3.zip |
Separate JalvLog from Jalv
-rw-r--r-- | src/jalv.c | 5 | ||||
-rw-r--r-- | src/jalv_internal.h | 2 | ||||
-rw-r--r-- | src/log.c | 11 | ||||
-rw-r--r-- | src/log.h | 6 |
4 files changed, 17 insertions, 7 deletions
@@ -845,6 +845,9 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) return ret; } + jalv->log.urids = &jalv->urids; + jalv->log.tracing = jalv->opts.trace; + jalv->symap = symap_new(); zix_sem_init(&jalv->symap_lock, 1); zix_sem_init(&jalv->work_lock, 1); @@ -938,7 +941,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) LV2_WORKER__schedule, &jalv->features.ssched); - jalv->features.llog.handle = jalv; + jalv->features.llog.handle = &jalv->log; jalv->features.llog.printf = jalv_printf; jalv->features.llog.vprintf = jalv_vprintf; init_feature(&jalv->features.log_feature, LV2_LOG__log, &jalv->features.llog); diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 538395d..68dabf5 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -6,6 +6,7 @@ #include "control.h" #include "jalv_config.h" +#include "log.h" #include "nodes.h" #include "options.h" #include "symap.h" @@ -64,6 +65,7 @@ struct JalvImpl { JalvOptions opts; ///< Command-line options JalvURIDs urids; ///< URIDs JalvNodes nodes; ///< Nodes + JalvLog log; ///< Log for error/warning/debug messages LV2_Atom_Forge forge; ///< Atom forge const char* prog_name; ///< Program name (argv[0]) LilvWorld* world; ///< Lilv World @@ -7,7 +7,6 @@ #include "jalv_config.h" #include "jalv_internal.h" -#include "options.h" #include "port.h" #include "urids.h" @@ -100,17 +99,17 @@ jalv_log(const JalvLogLevel level, const char* const fmt, ...) int jalv_vprintf(LV2_Log_Handle handle, LV2_URID type, const char* fmt, va_list ap) { - Jalv* const jalv = (Jalv*)handle; + JalvLog* const log = (JalvLog*)handle; - if (type == jalv->urids.log_Trace && jalv->opts.trace) { - return jalv_vlog(JALV_LOG_DEBUG, fmt, ap); + if (type == log->urids->log_Trace) { + return log->tracing ? jalv_vlog(JALV_LOG_DEBUG, fmt, ap) : 0; } - if (type == jalv->urids.log_Error) { + if (type == log->urids->log_Error) { return jalv_vlog(JALV_LOG_ERR, fmt, ap); } - if (type == jalv->urids.log_Warning) { + if (type == log->urids->log_Warning) { return jalv_vlog(JALV_LOG_WARNING, fmt, ap); } @@ -5,6 +5,7 @@ #define JALV_LOG_H #include "types.h" +#include "urids.h" #include "lv2/log/log.h" #include "lv2/urid/urid.h" @@ -32,6 +33,11 @@ typedef enum { JALV_LOG_DEBUG = 7, } JalvLogLevel; +typedef struct { + JalvURIDs* urids; + bool tracing; +} JalvLog; + void jalv_print_control(Jalv* jalv, const struct Port* port, float value); |