From: Daniel Elstner Date: Sun, 13 Sep 2015 10:32:03 +0000 (+0200) Subject: log: Bring back the "sr: " default log prefix X-Git-Tag: libsigrok-0.4.0~306 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=22c50ed973443db12a5569dbc3d698bf98167833;p=libsigrok.git log: Bring back the "sr: " default log prefix This got lost accidentally with the removal of the logdomain API. --- diff --git a/src/log.c b/src/log.c index 2265181e..87c77971 100644 --- a/src/log.c +++ b/src/log.c @@ -161,6 +161,7 @@ static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args { uint64_t elapsed_us, minutes; unsigned int rest_us, seconds, microseconds; + int ret; /* This specific log callback doesn't need the void pointer data. */ (void)cb_data; @@ -177,13 +178,14 @@ static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args seconds = rest_us / G_TIME_SPAN_SECOND; microseconds = rest_us % G_TIME_SPAN_SECOND; - if (fprintf(stderr, "[%.2" PRIu64 ":%.2u.%.6u] ", - minutes, seconds, microseconds) < 0) - return SR_ERR; + ret = fprintf(stderr, "sr: [%.2" PRIu64 ":%.2u.%.6u] ", + minutes, seconds, microseconds); + } else { + ret = fputs("sr: ", stderr); } - if (vfprintf(stderr, format, args) < 0) - return SR_ERR; - if (putc('\n', stderr) < 0) + + if (ret < 0 || vfprintf(stderr, format, args) < 0 + || putc('\n', stderr) < 0) return SR_ERR; return SR_OK;