From 8d68cab6ba3c16117be71f5ba22ff6c48f4576b0 Mon Sep 17 00:00:00 2001 From: Lorenz Cuno Klopfenstein Date: Sat, 18 Jan 2014 16:23:09 +0100 Subject: [PATCH] Issue #60: fixed access to shared log file with multiple application instances. --- OnTopReplica/Log.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OnTopReplica/Log.cs b/OnTopReplica/Log.cs index ac1f967..8d0bdb8 100644 --- a/OnTopReplica/Log.cs +++ b/OnTopReplica/Log.cs @@ -18,11 +18,8 @@ namespace OnTopReplica { Writer.AutoFlush = true; } catch (Exception) { + //TODO: provide fallback logging mechanism? Writer = null; - -#if DEBUG - throw; -#endif } } @@ -56,11 +53,17 @@ namespace OnTopReplica { } private static void WriteLine(string message) { + if (Writer == null) + return; + var s = string.Format("{0,-8:HH:mm:ss} {1}", DateTime.Now, message); Writer.WriteLine(s); } private static void WriteLines(params string[] messages) { + if (Writer == null) + return; + if (messages.Length > 0) WriteLine(messages[0]); if (messages.Length > 1) {