Mercurial > pub > ImplabNet
comparison Implab/Diagnostics/TraceContext.cs @ 94:a43745f81f10 v2
minor fixes
author | cin |
---|---|
date | Thu, 23 Oct 2014 17:50:09 +0400 |
parents | dc4942d09e74 |
children | 2573b562e328 |
comparison
equal
deleted
inserted
replaced
93:dc4942d09e74 | 94:a43745f81f10 |
---|---|
39 return m_current.CurrentOperation; | 39 return m_current.CurrentOperation; |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { | 43 public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { |
44 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Attach, String.Format("{0} -> [{1}]", operation.Name, m_threadId))); | 44 var prev = CurrentOperation; |
45 m_stack.Push(m_current); | 45 m_stack.Push(m_current); |
46 m_current = new OperationContext(operation, takeOwnership); | 46 m_current = new OperationContext(operation, takeOwnership); |
47 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); | |
47 } | 48 } |
48 | 49 |
49 public void StartLogicalOperation(string name) { | 50 public void StartLogicalOperation(string name) { |
50 m_current.BeginLogicalOperation(name); | 51 m_current.BeginLogicalOperation(name); |
51 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, String.Format("+{0}",CurrentOperation.Name))); | 52 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, String.Format("+{0}",CurrentOperation.Name))); |
59 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",CurrentOperation.Name, CurrentOperation.Duration))); | 60 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",CurrentOperation.Name, CurrentOperation.Duration))); |
60 m_current.EndLogicalOperation(); | 61 m_current.EndLogicalOperation(); |
61 } | 62 } |
62 | 63 |
63 public LogicalOperation DetachLogicalOperation() { | 64 public LogicalOperation DetachLogicalOperation() { |
64 var op = m_current.DetachLogicalOperation(); | 65 var prev = m_current.DetachLogicalOperation(); |
65 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("[{0}] -> {1}", m_threadId, op.Name))); | 66 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); |
66 return op; | 67 return prev; |
67 } | 68 } |
68 | 69 |
69 public void Leave() { | 70 public void Leave() { |
70 if (m_stack.Count > 0) { | 71 if (m_stack.Count > 0) { |
71 m_current.Leave(); | 72 m_current.Leave(); |
73 var prev = CurrentOperation; | |
72 m_current = m_stack.Pop(); | 74 m_current = m_stack.Pop(); |
75 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); | |
73 } else { | 76 } else { |
74 TraceLog.TraceWarning("Attemtp to leave the last operation context"); | 77 TraceLog.TraceWarning("Attemtp to leave the last operation context"); |
75 m_current = OperationContext.EMPTY; | 78 m_current = OperationContext.EMPTY; |
76 } | 79 } |
77 } | 80 } |