From 9e15dfdc3440cd8b08bfe4e6a79208376e853509 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 6 Jul 2018 14:12:48 +0200 Subject: [PATCH 1/2] log: only show indention markers in console logs, not files --- lib/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/log.c b/lib/log.c index fab1a89bf..50e414c04 100644 --- a/lib/log.c +++ b/lib/log.c @@ -304,12 +304,14 @@ void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list ap) /* Timestamp & Severity */ strcatf(&buf, "%10.3f %-5s ", time_delta(&l->epoch, &ts), lvl); - /* Indention */ + /* Indention in case we log to the terminal */ #ifdef __GNUC__ - for (int i = 0; i < indent; i++) - strcatf(&buf, "%s ", BOX_UD); + if (l->file == stderr || l->file == stdout) { + for (int i = 0; i < indent; i++) + strcatf(&buf, "%s ", BOX_UD); - strcatf(&buf, "%s ", BOX_UDR); + strcatf(&buf, "%s ", BOX_UDR); + } #endif /* Format String */ From 26541bae7936fa7053cd074777580ef661678ca1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 6 Jul 2018 14:13:01 +0200 Subject: [PATCH 2/2] log: fix logging to syslog --- lib/log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/log.c b/lib/log.c index 50e414c04..988239409 100644 --- a/lib/log.c +++ b/lib/log.c @@ -321,7 +321,11 @@ void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list ap) #ifdef ENABLE_OPAL_ASYNC OpalPrint("VILLASnode: %s\n", buf); #endif - fprintf(l->file ? l->file : stderr, "%s\n", buf); + if (l->file) + fprintf(l->file, "%s\n", buf); + + if (l->syslog) + vsyslog(LOG_INFO, fmt, ap); free(buf); }