[hyena] Add thread id to Hyena.Log when debugging.



commit 8356ffa694da3d737084df9243c014b3be3005f8
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sat Mar 27 13:13:25 2010 +0100

    Add thread id to Hyena.Log when debugging.
    
    This adds the thread id to the Hyena.Log output, which makes it possible to
    distinguish from which thread the message originated. This is only shown when
    Debugging is enabled, to avoid the overhead during normal usage.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=614094

 src/Hyena/Hyena/Log.cs |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/Hyena/Hyena/Log.cs b/src/Hyena/Hyena/Log.cs
index 0b06b12..c000cc1 100644
--- a/src/Hyena/Hyena/Log.cs
+++ b/src/Hyena/Hyena/Log.cs
@@ -29,6 +29,7 @@
 using System;
 using System.Text;
 using System.Collections.Generic;
+using System.Threading;
 
 namespace Hyena
 {
@@ -115,8 +116,14 @@ namespace Hyena
                     case LogEntryType.Debug: ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; break;
                 }
 
-                Console.Write ("[{0} {1:00}:{2:00}:{3:00}.{4:000}]", TypeString (type), DateTime.Now.Hour,
-                    DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
+                var thread_name = String.Empty;
+                if (Debugging) {
+                    var thread = Thread.CurrentThread;
+                    thread_name = String.Format ("{0} ", thread.ManagedThreadId);
+                }
+
+                Console.Write ("[{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);
 
                 ConsoleCrayon.ResetColor ();
 



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