Mercurial > pub > ImplabNet
view Implab/Diagnostics/ConsoleTraceListener.cs @ 205:8200ab154c8a v2
Added ResetState to RunnableComponent to reset in case of failure
Added StateChanged event to IRunnable
Renamed Promise.SUCCESS -> Promise.Success
Added Promise.FromException
Renamed Bundle -> PromiseAll in PromiseExtensions
author | cin |
---|---|
date | Tue, 25 Oct 2016 17:40:33 +0300 |
parents | 04d4c92d0f28 |
children |
line wrap: on
line source
using System; using System.Text; namespace Implab.Diagnostics { public class ConsoleTraceListener: ListenerBase { static readonly object _consoleLock = new object(); public override void Write(LogEventArgs args, object entry) { var msg = new StringBuilder(); for (int i = 0; i < args.Operation.Level; i++) msg.Append(" "); msg.AppendFormat("[{0}]: {1}", args.ThreadId, entry); lock (_consoleLock) { Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); Console.WriteLine(msg); } } } }