diff Implab/Diagnostics/TraceContext.cs @ 94:a43745f81f10 v2

minor fixes
author cin
date Thu, 23 Oct 2014 17:50:09 +0400
parents dc4942d09e74
children 2573b562e328
line wrap: on
line diff
--- a/Implab/Diagnostics/TraceContext.cs	Thu Oct 23 01:13:57 2014 +0400
+++ b/Implab/Diagnostics/TraceContext.cs	Thu Oct 23 17:50:09 2014 +0400
@@ -41,9 +41,10 @@
         }
 
         public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) {
-            LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Attach, String.Format("{0} -> [{1}]", operation.Name, m_threadId)));
+            var prev = CurrentOperation;
             m_stack.Push(m_current);
             m_current = new OperationContext(operation, takeOwnership);
+            LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name)));
         }
 
         public void StartLogicalOperation(string name) {
@@ -61,15 +62,17 @@
         }
 
         public LogicalOperation DetachLogicalOperation() {
-            var op = m_current.DetachLogicalOperation();
-            LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("[{0}] -> {1}", m_threadId, op.Name)));
-            return op;
+            var prev = m_current.DetachLogicalOperation();
+            LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name)));
+            return prev;
         }
 
         public void Leave() {
             if (m_stack.Count > 0) {
                 m_current.Leave();
+                var prev = CurrentOperation;
                 m_current = m_stack.Pop();
+                LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name)));
             } else {
                 TraceLog.TraceWarning("Attemtp to leave the last operation context");
                 m_current = OperationContext.EMPTY;