fallback to stdout if no writable logfile available
authorsheepluva
Wed, 27 Apr 2016 13:01:38 +0200
changeset 11743 eefa04b23c3b
parent 11742 35d1654b3c9a
child 11744 ac58a063d26a
fallback to stdout if no writable logfile available
hedgewars/uUtils.pas
--- a/hedgewars/uUtils.pas	Wed Apr 27 11:41:32 2016 +0200
+++ b/hedgewars/uUtils.pas	Wed Apr 27 13:01:38 2016 +0200
@@ -352,7 +352,10 @@
 {$IFDEF USE_VIDEO_RECORDING}
 EnterCriticalSection(logMutex);
 {$ENDIF}
-pfsWriteLn(logFile, inttostr(GameTicks)  + ': ' + s);
+if logFile <> nil then
+    pfsWriteLn(logFile, inttostr(GameTicks)  + ': ' + s)
+else
+    WriteLn(stdout, inttostr(GameTicks)  + ': ' + s);
 
 {$IFDEF USE_VIDEO_RECORDING}
 LeaveCriticalSection(logMutex);
@@ -544,6 +547,9 @@
             break;
         inc(i)
     end;
+
+    if logFile = nil then
+        WriteLn(stdout, '[WARNING] Could not open log file for writing. Log will be written to stdout!');
 {$ENDIF}
 
     //mobile stuff