aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-30 17:36:38 -0400
committerDavid Robillard <d@drobilla.net>2016-07-31 03:25:52 -0400
commit005f9bf2051725a197c3b79e769214f78bb23b16 (patch)
treef9aaf848e8cee8bd49cb98952834283ac232be62 /src
parentc001c7bd70ea3dee1aa1447f413c0d51e8e07415 (diff)
downloadjalv-005f9bf2051725a197c3b79e769214f78bb23b16.tar.gz
jalv-005f9bf2051725a197c3b79e769214f78bb23b16.tar.bz2
jalv-005f9bf2051725a197c3b79e769214f78bb23b16.zip
Clean up log output
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c19
-rw-r--r--src/jalv_internal.h12
-rw-r--r--src/log.c27
3 files changed, 47 insertions, 11 deletions
diff --git a/src/jalv.c b/src/jalv.c
index fa08e64..5d43691 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2015 David Robillard <http://drobilla.net>
+ Copyright 2007-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -73,6 +73,7 @@
#include "worker.h"
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
#ifndef MIN
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
@@ -493,7 +494,9 @@ jack_process_cb(jack_nframes_t nframes, void* data)
char* str = sratom_to_turtle(
jalv->sratom, &jalv->unmap, "time:", NULL, NULL,
lv2_pos->type, lv2_pos->size, LV2_ATOM_BODY(lv2_pos));
- printf("\n## Position\n%s\n", str);
+ jalv_ansi_start(stderr, 36);
+ printf("\n## Position ##\n%s\n", str);
+ jalv_ansi_reset(stderr);
free(str);
}
}
@@ -1009,8 +1012,18 @@ main(int argc, char** argv)
lv2_atom_forge_init(&jalv.forge, &jalv.map);
+ jalv.env = serd_env_new(NULL);
+ serd_env_set_prefix_from_strings(
+ jalv.env, (const uint8_t*)"patch", (const uint8_t*)LV2_PATCH_PREFIX);
+ serd_env_set_prefix_from_strings(
+ jalv.env, (const uint8_t*)"time", (const uint8_t*)LV2_TIME_PREFIX);
+ serd_env_set_prefix_from_strings(
+ jalv.env, (const uint8_t*)"xsd", (const uint8_t*)NS_XSD);
+
jalv.sratom = sratom_new(&jalv.map);
jalv.ui_sratom = sratom_new(&jalv.map);
+ sratom_set_env(jalv.sratom, jalv.env);
+ sratom_set_env(jalv.ui_sratom, jalv.env);
jalv.midi_event_id = uri_to_id(
&jalv, "http://lv2plug.in/ns/ext/event", LV2_MIDI__MidiEvent);
@@ -1024,7 +1037,9 @@ main(int argc, char** argv)
jalv.urids.bufsz_maxBlockLength = symap_map(jalv.symap, LV2_BUF_SIZE__maxBlockLength);
jalv.urids.bufsz_minBlockLength = symap_map(jalv.symap, LV2_BUF_SIZE__minBlockLength);
jalv.urids.bufsz_sequenceSize = symap_map(jalv.symap, LV2_BUF_SIZE__sequenceSize);
+ jalv.urids.log_Error = symap_map(jalv.symap, LV2_LOG__Error);
jalv.urids.log_Trace = symap_map(jalv.symap, LV2_LOG__Trace);
+ jalv.urids.log_Warning = symap_map(jalv.symap, LV2_LOG__Warning);
jalv.urids.midi_MidiEvent = symap_map(jalv.symap, LV2_MIDI__MidiEvent);
jalv.urids.param_sampleRate = symap_map(jalv.symap, LV2_PARAMETERS__sampleRate);
jalv.urids.patch_Get = symap_map(jalv.symap, LV2_PATCH__Get);
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 4f5b526..7aa9e9e 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2015 David Robillard <http://drobilla.net>
+ Copyright 2007-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -171,7 +171,9 @@ typedef struct {
LV2_URID bufsz_maxBlockLength;
LV2_URID bufsz_minBlockLength;
LV2_URID bufsz_sequenceSize;
+ LV2_URID log_Error;
LV2_URID log_Trace;
+ LV2_URID log_Warning;
LV2_URID midi_MidiEvent;
LV2_URID param_sampleRate;
LV2_URID patch_Get;
@@ -252,6 +254,7 @@ struct Jalv {
LilvWorld* world; ///< Lilv World
LV2_URID_Map map; ///< URI => Int map
LV2_URID_Unmap unmap; ///< Int => URI map
+ SerdEnv* env; ///< Environment for RDF printing
Sratom* sratom; ///< Atom serialiser
Sratom* ui_sratom; ///< Atom serialiser for UI thread
Symap* symap; ///< URI map
@@ -423,14 +426,15 @@ jalv_vprintf(LV2_Log_Handle handle,
const char* fmt,
va_list ap);
-static inline void
+static inline bool
jalv_ansi_start(FILE* stream, int color)
{
#ifdef HAVE_ISATTY
if (isatty(fileno(stream))) {
- fprintf(stream, "\033[0;%dm\n", color);
+ return fprintf(stream, "\033[0;%dm", color);
}
#endif
+ return 0;
}
static inline void
@@ -438,7 +442,7 @@ jalv_ansi_reset(FILE* stream)
{
#ifdef HAVE_ISATTY
if (isatty(fileno(stream))) {
- fprintf(stream, "\033[0m\n");
+ fprintf(stream, "\033[0m");
}
#endif
}
diff --git a/src/log.c b/src/log.c
index e4b5a8b..45a8f59 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2012 David Robillard <http://drobilla.net>
+ Copyright 2007-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -35,9 +35,26 @@ jalv_vprintf(LV2_Log_Handle handle,
va_list ap)
{
// TODO: Lock
- Jalv* jalv = (Jalv*)handle;
- if (type == jalv->urids.log_Trace && !jalv->opts.trace) {
- return 0;
+ Jalv* jalv = (Jalv*)handle;
+ bool fancy = true;
+ if (type == jalv->urids.log_Trace && jalv->opts.trace) {
+ jalv_ansi_start(stderr, 32);
+ fprintf(stderr, "trace: ");
+ } else if (type == jalv->urids.log_Error) {
+ jalv_ansi_start(stderr, 31);
+ fprintf(stderr, "error: ");
+ } else if (type == jalv->urids.log_Warning) {
+ jalv_ansi_start(stderr, 33);
+ fprintf(stderr, "warning: ");
+ } else {
+ fancy = false;
}
- return vfprintf(stderr, fmt, ap);
+
+ const int st = vfprintf(stderr, fmt, ap);
+
+ if (fancy) {
+ jalv_ansi_reset(stderr);
+ }
+
+ return st;
}