]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
log: always log to stderr
authorVincent Bernat <vincent@bernat.im>
Mon, 16 May 2016 06:46:57 +0000 (08:46 +0200)
committerVincent Bernat <vincent@bernat.im>
Mon, 16 May 2016 06:46:57 +0000 (08:46 +0200)
Otherwise, error messages are not displayed on startup and this may
confuse users.

NEWS
src/log.c

diff --git a/NEWS b/NEWS
index 3b9570d712cabe29a717f373c98e411b46e550d4..4acc6e97a4a91a5e99f7481b51f87dc6f67a4a5f 100644 (file)
--- 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:
index 332ce99947858b9faa499e3e13fac83c1071966e..1de756c7c62eca7e568354ebb73d76e205d59a18 100644 (file)
--- 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);
 }