Mercurial > pub > ImplabNet
diff Implab/Diagnostics/TextFileListener.cs @ 134:04d4c92d0f28 v2
Improved logging
author | cin |
---|---|
date | Wed, 11 Feb 2015 02:12:15 +0300 |
parents | 4c0e5ef99986 |
children | d45bdf510514 |
line wrap: on
line diff
--- a/Implab/Diagnostics/TextFileListener.cs Mon Feb 09 00:28:13 2015 +0300 +++ b/Implab/Diagnostics/TextFileListener.cs Wed Feb 11 02:12:15 2015 +0300 @@ -3,22 +3,22 @@ using System.Text; namespace Implab.Diagnostics { - public class TextFileListener: TextListenerBase { + public class TextFileListener: ListenerBase { readonly TextWriter m_textWriter; - public TextFileListener(string fileName, bool global) - : base(global) { + public TextFileListener(string fileName) { m_textWriter = File.CreateText(fileName); m_textWriter.WriteLine("LOG {0}", DateTime.Now); - Register(this); } - protected override void WriteEntry(LogEventArgs args, EventText text, string channel) { + #region implemented abstract members of ListenerBase + + public override void Write(LogEventArgs args, object entry) { var msg = new StringBuilder(); - for (int i = 0; i < text.indent; i++) + for (int i = 0; i < args.Operation.Level; i++) msg.Append(" "); - msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, channel, text.content); + msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.ChannelName, entry); lock (m_textWriter) { if (!IsDisposed) { @@ -29,7 +29,8 @@ } } - + #endregion + protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) {