tidying
[exim.git] / src / src / log.c
index 9cde369c0a5364ed46f73db319c7b589f1e9e06a..678c02be79d948b8f082af0d2625d904da3fc627 100644 (file)
@@ -145,8 +145,6 @@ write_syslog(int priority, const uschar *s)
 int len, pass;
 int linecount = 0;
 
-if (running_in_test_harness) return;
-
 if (!syslog_pid && LOGGING(pid))
   s = string_sprintf("%.*s%s", (int)pid_position[0], s, s + pid_position[1]);
 if (!syslog_timestamp)
@@ -159,7 +157,7 @@ if (!syslog_timestamp)
 len = Ustrlen(s);
 
 #ifndef NO_OPENLOG
-if (!syslog_open)
+if (!syslog_open && !f.running_in_test_harness)
   {
 # ifdef SYSLOG_LOG_PID
   openlog(CS syslog_processname, LOG_PID|LOG_CONS, syslog_facility);
@@ -189,15 +187,23 @@ for (pass = 0; pass < 2; pass++)
     tlen -= plen;
     if (ss[plen] == '\n') tlen--;    /* chars left */
 
-    if (pass == 0) linecount++; else
-      {
+    if (pass == 0)
+      linecount++;
+    else if (f.running_in_test_harness)
+      if (linecount == 1)
+        fprintf(stderr, "SYSLOG: '%.*s'\n", plen, ss);
+      else
+        fprintf(stderr, "SYSLOG: '[%d%c%d] %.*s'\n", i,
+          ss[plen] == '\n' && tlen != 0 ? '\\' : '/',
+          linecount, plen, ss);
+    else
       if (linecount == 1)
         syslog(priority, "%.*s", plen, ss);
       else
         syslog(priority, "[%d%c%d] %.*s", i,
           ss[plen] == '\n' && tlen != 0 ? '\\' : '/',
           linecount, plen, ss);
-      }
+
     ss += plen;
     if (*ss == '\n') ss++;
     }
@@ -235,7 +241,7 @@ if (s1)
   if (log_stderr && log_stderr != debug_file)
     fprintf(log_stderr, "%s\n", s1);
   }
-if (receive_call_bombout) receive_bomb_out(NULL, s2);  /* does not return */
+if (f.receive_call_bombout) receive_bomb_out(NULL, s2);  /* does not return */
 if (smtp_input) smtp_closedown(s2);
 exim_exit(EXIT_FAILURE, NULL);
 }
@@ -554,13 +560,13 @@ log_config_info(uschar *ptr, int flags)
 Ustrcpy(ptr, "Exim configuration error");
 ptr += 24;
 
-if ((flags & (LOG_CONFIG_FOR & ~LOG_CONFIG)) != 0)
+if (flags & (LOG_CONFIG_FOR & ~LOG_CONFIG))
   {
   Ustrcpy(ptr, " for ");
   return ptr + 5;
   }
 
-if ((flags & (LOG_CONFIG_IN & ~LOG_CONFIG)) != 0)
+if (flags & (LOG_CONFIG_IN & ~LOG_CONFIG))
   ptr += sprintf(CS ptr, " in line %d of %s", config_lineno, config_filename);
 
 Ustrcpy(ptr, ":\n  ");
@@ -889,7 +895,7 @@ if (!(flags & (LOG_MAIN|LOG_PANIC|LOG_REJECT)))
 
 /* There are some weird circumstances in which logging is disabled. */
 
-if (disable_logging)
+if (f.disable_logging)
   {
   DEBUG(D_any) debug_printf("log writing disabled\n");
   return;
@@ -912,7 +918,7 @@ if (LOGGING(pid))
   if (!syslog_pid) pid_position[1] = ptr - log_buffer; /*  … and end+1 of the PID */
   }
 
-if (really_exim && message_id[0] != 0)
+if (f.really_exim && message_id[0] != 0)
   ptr += sprintf(CS ptr, "%s ", message_id);
 
 if (flags & LOG_CONFIG) ptr = log_config_info(ptr, flags);
@@ -955,7 +961,7 @@ length = ptr - log_buffer;
 Write to log_stderr unless debugging (when it will already have been written),
 or unless there is no log_stderr (expn called from daemon, for example). */
 
-if (!really_exim || log_testing_mode)
+if (!f.really_exim || f.log_testing_mode)
   {
   if (  !debug_selector
      && log_stderr