aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c5
-rw-r--r--src/jalv_internal.h2
-rw-r--r--src/log.c11
-rw-r--r--src/log.h6
4 files changed, 17 insertions, 7 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 609fcb9..c241f93 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -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
diff --git a/src/log.c b/src/log.c
index ae7b126..d6456d5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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);
}
diff --git a/src/log.h b/src/log.h
index f5b9b08..a2b7629 100644
--- a/src/log.h
+++ b/src/log.h
@@ -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);