comparison Implab/Diagnostics/TraceContext.cs @ 134:04d4c92d0f28 v2

Improved logging
author cin
date Wed, 11 Feb 2015 02:12:15 +0300
parents 6c49d02a9a05
children ea485487a424
comparison
equal deleted inserted replaced
133:6c49d02a9a05 134:04d4c92d0f28
40 } 40 }
41 } 41 }
42 42
43 public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { 43 public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) {
44 //var prev = CurrentOperation; 44 //var prev = CurrentOperation;
45 //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name)));
45 m_stack.Push(m_current); 46 m_stack.Push(m_current);
46 m_current = new OperationContext(operation, takeOwnership); 47 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)));
48 } 48 }
49 49
50 public void StartLogicalOperation(string name) { 50 public void StartLogicalOperation(string name) {
51 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, name));
51 m_current.BeginLogicalOperation(name); 52 m_current.BeginLogicalOperation(name);
52 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationStarted, String.Format("+{0}",CurrentOperation.Name)));
53 } 53 }
54 54
55 public void StartLogicalOperation() { 55 public void StartLogicalOperation() {
56 StartLogicalOperation(String.Empty); 56 StartLogicalOperation(String.Empty);
57 } 57 }
58 58
59 public void EndLogicalOperation() { 59 public void EndLogicalOperation() {
60 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",CurrentOperation.Name, CurrentOperation.Duration))); 60 var op = m_current.EndLogicalOperation();
61 m_current.EndLogicalOperation(); 61 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",op.Name, op.Duration)));
62 } 62 }
63 63
64 public LogicalOperation DetachLogicalOperation() { 64 public LogicalOperation DetachLogicalOperation() {
65 var prev = m_current.DetachLogicalOperation(); 65 var prev = m_current.DetachLogicalOperation();
66 //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); 66 //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name)));