From 62bcad5563a36fe9ff73839c14f692839815e0d4 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 14 Mar 2018 16:10:52 +0000 Subject: [PATCH] logger: Don't crash when not able to write to log --- Sparkles/Logger.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sparkles/Logger.cs b/Sparkles/Logger.cs index f6a4c896..80c70779 100644 --- a/Sparkles/Logger.cs +++ b/Sparkles/Logger.cs @@ -49,8 +49,14 @@ namespace Sparkles { Console.WriteLine (line); lock (log_writer_lock) { - log_writer.WriteLine (line); - log_writer.Flush (); + try { + log_writer.WriteLine (line); + log_writer.Flush (); + + } catch (Exception e) { + Console.WriteLine (string.Format ("Could not write to log {0}: {1} {2}", + (log_writer.BaseStream as FileStream).Name, e.Message, e.StackTrace)); + } } }