From 005f9bf2051725a197c3b79e769214f78bb23b16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 30 Jul 2016 17:36:38 -0400 Subject: Clean up log output --- src/log.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/log.c') 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 + Copyright 2007-2016 David Robillard 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; } -- cgit v1.2.1