[chronojump] Safer logB



commit eee95d24019454f7ba21e74d7a112433325e5566
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Nov 21 17:27:35 2016 +0100

    Safer logB

 src/logB.cs |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/logB.cs b/src/logB.cs
index 4b03140..30c47ce 100644
--- a/src/logB.cs
+++ b/src/logB.cs
@@ -242,24 +242,29 @@ public static class LogB
                        string lineStart = string.Format("[{5}{0} {1:00}:{2:00}:{3:00}.{4:000}]", 
TypeString(type), DateTime.Now.Hour,
                                        DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond, 
thread_name);
 
-                       if(PrintAllThreads || printNow) {
-                               //try {
+                       if(PrintAllThreads || printNow)
+                       {
+                               try {
                                        Console.Write(lineStart);
        
                                        ConsoleCrayon.ResetColor();
        
                                        message += LogSync.ReadAndEmpty();
        
-                                       if(details != null) {
+                                       if(details != null)
                                                Console.WriteLine(" {0} - {1}", message, details);
-                                       } else {
+                                       else {
                                                if(type == LogEntryType.Debug)
                                                        Console.Write(" {0}", message);
                                                else
                                                        Console.WriteLine(" {0}", message);
                                        }
-                               //} catch (System.IndexOutOfRangeException e) {
-                               //}
+                               } catch (System.IndexOutOfRangeException e)
+                               {
+                                       //Sometimes logB crashes on printing
+                                       Console.WriteLine("CATCHED AT LOGB:");
+                                       Console.WriteLine("message: {0}", message);
+                               }
                        } else {
                                LogSync.Add(lineStart + "\n" + message);
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]