comparison Implab/Diagnostics/ConsoleTraceListener.cs @ 48:d9d794b61bb9 interactive logger

Interactive tracing Improved working with tracing contexts
author cin
date Fri, 18 Apr 2014 12:34:45 +0400
parents 7c2369f580b8
children 4c0e5ef99986
comparison
equal deleted inserted replaced
47:b181f7bcb259 48:d9d794b61bb9
11 public ConsoleTraceListener() 11 public ConsoleTraceListener()
12 : base(true) { 12 : base(true) {
13 13
14 } 14 }
15 15
16 public ConsoleTraceListener(bool local) 16 public ConsoleTraceListener(bool global)
17 : base(local) { 17 : base(global) {
18 18
19 } 19 }
20 20
21 protected override void WriteEntry(TraceContext context, EventText text) { 21 protected override void WriteEntry(TraceContext context, EventText text, string channel) {
22 var msg = new StringBuilder(); 22 var msg = new StringBuilder();
23 23
24 for (int i = 0; i < text.indent; i++) 24 for (int i = 0; i < text.indent; i++)
25 msg.Append(" "); 25 msg.Append(" ");
26 msg.AppendFormat("[{0}]: {1}", context.ThreadId, text.content); 26 msg.AppendFormat("[{0}]:{1}: {2}", context.ThreadId, channel, text.content);
27 27
28 lock (_consoleLock) { 28 lock (_consoleLock) {
29 Console.ForegroundColor = (ConsoleColor)(context.ThreadId % 15 + 1); 29 Console.ForegroundColor = (ConsoleColor)(context.ThreadId % 15 + 1);
30 Console.WriteLine(msg.ToString()); 30 Console.WriteLine(msg.ToString());
31 } 31 }