]> granicus.if.org Git - fcron/commitdiff
only call xopenlog when necessary
authorThibault Godouet <fcron@free.fr>
Tue, 1 Jan 2013 18:13:34 +0000 (18:13 +0000)
committerThibault Godouet <fcron@free.fr>
Tue, 1 Jan 2013 18:13:34 +0000 (18:13 +0000)
log.c

diff --git a/log.c b/log.c
index c1df1dbc77dc837a6d062bed7a0bdc0f20c04adc..25565e5524f6f3f7bd8ce7955fc62fc3d02f5c17 100644 (file)
--- a/log.c
+++ b/log.c
@@ -157,9 +157,8 @@ make_msg(const char *append, char *fmt, va_list args)
 void
 log_syslog_str(int priority, char *msg)
 {
-    xopenlog();
-
     if (dosyslog) {
+        xopenlog();
        syslog(priority, "%s", msg);
     }
 }
@@ -170,6 +169,8 @@ log_file_str(FILE *logfile, int priority, char *msg)
 {
     xopenlog();
 
+    /* we may have failed to open the logfile - check if
+     * it does exist *after* xopenlog() */
     if (logfile != NULL) {
        print_line_prefix(logfile, priority);
         fprintf(logfile, "%s\n", msg);