Package: emmax / 0~beta.20100307-6

logfile.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Author: Steffen Moeller
Last-Update: 2013-06-11
Description: Log only if file pointer exists

Index: emmax-0~beta.20100307/emmax.c
===================================================================
--- emmax-0~beta.20100307.orig/emmax.c
+++ emmax-0~beta.20100307/emmax.c
@@ -1529,11 +1529,14 @@
 
 void emmax_error( const char* format, ... ) {
   va_list args;
-  fprintf(g_logh.fp, "ERROR: ");
-  va_start (args, format);
-  vfprintf(g_logh.fp, format, args);
-  va_end (args);
-  fprintf(g_logh.fp,"\n");
+  if (g_logh.fp) {
+     // the logfile may not be available
+     fprintf(g_logh.fp, "ERROR: ");
+     va_start (args, format);
+     vfprintf(g_logh.fp, format, args);
+     va_end (args);
+     fprintf(g_logh.fp,"\n");
+  }
 
   fprintf(stderr, "ERROR: ");
   va_start (args, format);