Skip to content

Commit

Permalink
Issue #60: fixed access to shared log file with multiple application …
Browse files Browse the repository at this point in the history
…instances.
  • Loading branch information
LorenzCK committed Jan 18, 2014
1 parent 076a8ca commit 8d68cab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions OnTopReplica/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ static Log() {
Writer.AutoFlush = true;
}
catch (Exception) {
//TODO: provide fallback logging mechanism?
Writer = null;

#if DEBUG
throw;
#endif
}
}

Expand Down Expand Up @@ -56,11 +53,17 @@ public static void WriteException(string message, Exception exception) {
}

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) {
Expand Down

0 comments on commit 8d68cab

Please sign in to comment.