Mercurial > pub > ImplabNet
diff Implab/Diagnostics/TextListenerBase.cs @ 50:f8cbe84cfdb1
Слияние с interactive logger
author | cin |
---|---|
date | Fri, 18 Apr 2014 12:37:48 +0400 |
parents | d9d794b61bb9 |
children | 4c0e5ef99986 |
line wrap: on
line diff
--- a/Implab/Diagnostics/TextListenerBase.cs Wed Apr 16 19:02:58 2014 +0400 +++ b/Implab/Diagnostics/TextListenerBase.cs Fri Apr 18 12:37:48 2014 +0400 @@ -10,9 +10,9 @@ readonly LogicalOperation m_boundOperation; readonly int m_baseIndent; - protected TextListenerBase(bool local) { + protected TextListenerBase(bool global) { Register(this); - if (local) { + if (!global) { m_boundOperation = TraceContext.Current.CurrentOperation; m_baseIndent = Math.Max(0, m_boundOperation.Level - 1); } @@ -36,6 +36,7 @@ AssertNotDisposed(); var formatter = GetService<IEventTextFormatter<TEvent>>(); + var channelName = channel.Name; EventHandler<ValueEventArgs<TEvent>> handler = (sender, args) => { TraceContext context = (TraceContext)sender; @@ -43,7 +44,7 @@ text.indent -= m_baseIndent; if (IsRelated(context.CurrentOperation)) - WriteEntry(context, text); + WriteEntry(context, text, channelName); }; if (m_subscriptions.ContainsKey(channel)) @@ -89,7 +90,16 @@ } } - protected abstract void WriteEntry(TraceContext context, EventText text); + /// <summary> + /// Вызывается для записи текста сообщения, в журнал. + /// </summary> + /// <remarks> + /// Данный метод может вызваться из разных потоков одновременно. Возможна ситуация, когда + /// данный метод вызывается уже после освобождения ообъекта методом <see cref="Dispose()"/>. + /// </remarks> + /// <param name="context">Контекст трассировки.</param> + /// <param name="text">Текст сообщения.</param> + protected abstract void WriteEntry(TraceContext context, EventText text, string channel); public EventText Format(TraceContext context, object data) { return new EventText { @@ -110,10 +120,10 @@ } protected override void Dispose(bool disposing) { + base.Dispose(disposing); if (disposing) { UnsubscribeAll(); } - base.Dispose(disposing); } } }