aboutsummaryrefslogtreecommitdiff
path: root/sandbox_ui.lv2
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-12 19:14:25 +0100
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2018-01-12 19:14:25 +0100
commit603b967549bd63de27b782bd724fec3cdcf8533b (patch)
tree98d55c912faf21223cf75cb7f72fe3e6aa82564e /sandbox_ui.lv2
parent038389d4937898608dcb5d437d60cd18446c27f7 (diff)
downloadsynthpod-603b967549bd63de27b782bd724fec3cdcf8533b.zip
synthpod-603b967549bd63de27b782bd724fec3cdcf8533b.tar.gz
synthpod-603b967549bd63de27b782bd724fec3cdcf8533b.tar.bz2
synthpod-603b967549bd63de27b782bd724fec3cdcf8533b.tar.xz
nk: tokenize log messages at newlines.
Diffstat (limited to 'sandbox_ui.lv2')
-rw-r--r--sandbox_ui.lv2/sandbox_slave.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sandbox_ui.lv2/sandbox_slave.c b/sandbox_ui.lv2/sandbox_slave.c
index 539feda..68a3ea5 100644
--- a/sandbox_ui.lv2/sandbox_slave.c
+++ b/sandbox_ui.lv2/sandbox_slave.c
@@ -145,11 +145,29 @@ _log_vprintf(LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list args
else if(type == sb->log_warning)
idx = COLOR_WARNING;
- const int istty = isatty(STDERR_FILENO);
- fprintf(stderr, "%s %s ", prefix[istty][COLOR_UI], prefix[istty][idx]);
- if(sb->plugin_urn)
- fprintf(stderr, "%s%s%s ", prefix[istty][COLOR_URN1], sb->plugin_urn, prefix[istty][COLOR_URN2]);
- return vfprintf(stderr, fmt, args);
+ char *buf;
+ if(vasprintf(&buf, fmt, args) == -1)
+ buf = NULL;
+
+ if(buf)
+ {
+ const int istty = isatty(STDERR_FILENO);
+ const char *sep = "\n";
+ for(char *bufp = buf, *pch = strsep(&bufp, sep);
+ pch;
+ pch = strsep(&bufp, sep) )
+ {
+ if(strlen(pch))
+ {
+ fprintf(stderr, "%s %s ", prefix[istty][COLOR_UI], prefix[istty][idx]);
+ if(sb->plugin_urn)
+ fprintf(stderr, "%s%s%s ", prefix[istty][COLOR_URN1], sb->plugin_urn, prefix[istty][COLOR_URN2]);
+ fprintf(stderr, "%s\n", pch);
+ }
+ }
+
+ free(buf);
+ }
return 0;
}