aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
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/log.c
parentc001c7bd70ea3dee1aa1447f413c0d51e8e07415 (diff)
downloadjalv-005f9bf2051725a197c3b79e769214f78bb23b16.tar.gz
jalv-005f9bf2051725a197c3b79e769214f78bb23b16.tar.bz2
jalv-005f9bf2051725a197c3b79e769214f78bb23b16.zip
Clean up log output
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c27
1 files changed, 22 insertions, 5 deletions
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;
}