From: Vincent Bernat Date: Mon, 16 May 2016 06:46:57 +0000 (+0200) Subject: log: always log to stderr X-Git-Tag: 0.9.3~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b5463687985b56f6fccdff48a7fa318eb87ad668;p=thirdparty%2Flldpd.git log: always log to stderr Otherwise, error messages are not displayed on startup and this may confuse users. --- diff --git a/NEWS b/NEWS index 3b9570d7..4acc6e97 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ lldpd (0.9.3) * Change: + Do not rely on support of constructors for liblldpctl. + + Always log to stderr (even in addition to syslog). lldpd (0.9.2) * Change: diff --git a/src/log.c b/src/log.c index 332ce999..1de756c7 100644 --- a/src/log.c +++ b/src/log.c @@ -145,23 +145,26 @@ vlog(int pri, const char *token, const char *fmt, va_list ap) } /* Otherwise, fallback to output on stderr. */ } - if (!use_syslog || logh) { - char *nfmt; - /* best effort in out of mem situations */ - if (asprintf(&nfmt, "%s %s%s%s]%s %s\n", - date(), - translate(STDERR_FILENO, pri), - token ? "/" : "", token ? token : "", - isatty(STDERR_FILENO) ? "\033[0m" : "", - fmt) == -1) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); - } else { - vfprintf(stderr, nfmt, ap); - free(nfmt); - } - fflush(stderr); - } else + + /* Log to standard error in all cases */ + char *nfmt; + /* best effort in out of mem situations */ + if (asprintf(&nfmt, "%s %s%s%s]%s %s\n", + date(), + translate(STDERR_FILENO, pri), + token ? "/" : "", token ? token : "", + isatty(STDERR_FILENO) ? "\033[0m" : "", + fmt) == -1) { + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } else { + vfprintf(stderr, nfmt, ap); + free(nfmt); + } + fflush(stderr); + + /* Log to syslog if requested */ + if (use_syslog) vsyslog(pri, fmt, ap); }