annotate Implab/Diagnostics/TraceContext.cs @ 66:790e8a997d30

Refactoring
author cin
date Thu, 14 Aug 2014 18:08:09 +0400
parents edf0bc558596
children c761fc982e1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
1 using System;
313f708a50e9 improved log concept
cin
parents:
diff changeset
2 using System.Collections.Generic;
313f708a50e9 improved log concept
cin
parents:
diff changeset
3 using System.Linq;
313f708a50e9 improved log concept
cin
parents:
diff changeset
4 using System.Text;
313f708a50e9 improved log concept
cin
parents:
diff changeset
5 using System.Threading;
313f708a50e9 improved log concept
cin
parents:
diff changeset
6 using System.Threading.Tasks;
313f708a50e9 improved log concept
cin
parents:
diff changeset
7
313f708a50e9 improved log concept
cin
parents:
diff changeset
8 namespace Implab.Diagnostics {
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
9 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
10 /// Контекст трассировки, привязывается к потоку и содержит в себе информацию о стеке логических операций.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
11 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
12 /// <remarks>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
13 /// Контекст трассировки передается слушателям событий для определения места, где возникло событие.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
14 /// </remarks>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
15 public class TraceContext {
313f708a50e9 improved log concept
cin
parents:
diff changeset
16 LogicalOperation m_currentOperation;
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
17 readonly LogicalOperation m_bound;
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
18 readonly int m_threadId;
313f708a50e9 improved log concept
cin
parents:
diff changeset
19
313f708a50e9 improved log concept
cin
parents:
diff changeset
20 [ThreadStatic]
313f708a50e9 improved log concept
cin
parents:
diff changeset
21 static TraceContext _current;
313f708a50e9 improved log concept
cin
parents:
diff changeset
22
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
23 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
24 /// Текущий контекст трассировки для потока, создается астоматически при первом обращении.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
25 /// </summary>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
26 public static TraceContext Current {
313f708a50e9 improved log concept
cin
parents:
diff changeset
27 get {
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
28 if (_current == null) {
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
29 _current = new TraceContext();
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
30 _current.LogEvent(TraceEventType.Created,"[{0}]", _current.ThreadId);
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
31 }
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
32 return _current;
313f708a50e9 improved log concept
cin
parents:
diff changeset
33 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
34 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
35
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
36 TraceContext(TraceContext context)
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
37 : this(context, false) {
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
38 }
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
39
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
40 TraceContext(TraceContext context, bool attach) {
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
41 if (context == null)
313f708a50e9 improved log concept
cin
parents:
diff changeset
42 throw new ArgumentNullException("context");
313f708a50e9 improved log concept
cin
parents:
diff changeset
43
313f708a50e9 improved log concept
cin
parents:
diff changeset
44 m_currentOperation = context.CurrentOperation;
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
45 m_bound = attach ? context.BoundOperation : context.CurrentOperation;
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
46 m_threadId = Thread.CurrentThread.ManagedThreadId;
313f708a50e9 improved log concept
cin
parents:
diff changeset
47 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
48
313f708a50e9 improved log concept
cin
parents:
diff changeset
49 TraceContext() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
50 m_currentOperation = new LogicalOperation();
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
51 m_bound = m_currentOperation;
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
52 m_threadId = Thread.CurrentThread.ManagedThreadId;
313f708a50e9 improved log concept
cin
parents:
diff changeset
53 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
54
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
55 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
56 /// При необходимости копирует состояние контекста трассивровки в текущий поток.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
57 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
58 /// <param name="from">Исходный контекст трассировки, который передается.</param>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
59 /// <remarks>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
60 /// <para>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
61 /// Копирование происходит за счет создания нового контекста трассировки и заполнением его
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
62 /// состояния из переданного контекста. При этом копируется стек операций, однако в новом
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
63 /// контексте ранее начатые логические операции не могут быть завершены.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
64 /// </para>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
65 /// <para>
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
66 /// Если передача состояния состоялась, то вызывается событие трассировки <see cref="TraceEventType.Fork"/>.
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
67 /// </para>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
68 /// </remarks>
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
69 public static void Fork(TraceContext from) {
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
70 if (_current == from)
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
71 return;
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
72 if (from != null) {
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
73 var context = new TraceContext(from);
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
74 context.LogEvent(TraceEventType.Fork, "[{0}]-->[{1}]",from.ThreadId, context.ThreadId);
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
75 _current = context;
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
76 } else {
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
77 _current = new TraceContext();
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
78 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
79 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
80
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
81 /// <summary>
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
82 /// Задает текущему потоку указанный контекст, текущей поток может заканчивать ранее начатые
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
83 /// логические операции в указанном контексте.
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
84 /// </summary>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
85 /// <param name="source"></param>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
86 public static void Attach(TraceContext source) {
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
87 if (_current == source)
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
88 return;
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
89 if (source != null) {
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
90 var context = new TraceContext(source, true);
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
91 context.LogEvent(TraceEventType.Attach, "[{0}]-->[{1}]", source.ThreadId, context.ThreadId);
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
92 _current = context;
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
93 } else {
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
94 _current = new TraceContext();
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
95 }
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
96 }
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
97
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
98 /// <summary>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
99 /// Отсоединяет текущий контекст трассировки от потока, для дальнейшей его передачи другому потоку
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
100 /// <see cref="Attach(TraceContext)"/>.
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
101 /// </summary>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
102 /// <returns>Контекст трассировки потока</returns>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
103 /// <remarks>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
104 /// После отсоединения контекста трассировки от потока, при первом обращении к трассировке в этом
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
105 /// потоке будет создан новый контекст.
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
106 /// </remarks>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
107 public static TraceContext Detach() {
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
108 var context = Current;
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
109 context.LogEvent(TraceEventType.Detach, null);
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
110 _current = null;
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
111 return context;
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
112 }
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
113
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
114 /// <summary>
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
115 /// Создает постоянную копию текущего контекста, данную копию можно хранить и использовать для передачи через <see cref="Fork(TraceContext)"/>
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
116 /// </summary>
41
2fc0fbe7d58b Added TraceContext support to array traits
cin
parents: 40
diff changeset
117 /// <returns>Копия текущего контекста трассировки.</returns>
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
118 public static TraceContext Snapshot() {
52
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
119 return _current == null ? new TraceContext() : new TraceContext(_current,false);
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
120 }
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
121
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
122 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
123 /// Выполняет переданное действие в указанном контексте трассировки, по окончании восстанавливает предыдущий контекст трассировки потока.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
124 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
125 /// <param name="action"></param>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
126 public void Invoke(Action action) {
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
127 if (action == null)
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
128 throw new ArgumentNullException("action");
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
129 var old = _current;
48
d9d794b61bb9 Interactive tracing
cin
parents: 43
diff changeset
130 Fork(this);
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
131 try {
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
132 action();
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
133 } finally {
52
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
134 if(_current != null)
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
135 _current.EndAllOperations();
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
136 _current = old;
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
137 }
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
138 }
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
139
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
140 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
141 /// Текущая логическая операция.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
142 /// </summary>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
143 public LogicalOperation CurrentOperation {
313f708a50e9 improved log concept
cin
parents:
diff changeset
144 get {
313f708a50e9 improved log concept
cin
parents:
diff changeset
145 return m_currentOperation;
313f708a50e9 improved log concept
cin
parents:
diff changeset
146 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
147 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
148
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
149 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
150 /// Операция ниже которой нельзя опускаться в стеке логических операций, т.е. она не может быть завершена в текущем контексте.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
151 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
152 public LogicalOperation BoundOperation {
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
153 get {
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
154 return m_bound;
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
155 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
156 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
157
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
158 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
159 /// Поток, в котором создан контекст трассировки.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
160 /// </summary>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
161 public int ThreadId {
313f708a50e9 improved log concept
cin
parents:
diff changeset
162 get {
313f708a50e9 improved log concept
cin
parents:
diff changeset
163 return m_threadId;
313f708a50e9 improved log concept
cin
parents:
diff changeset
164 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
165 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
166
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
167 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
168 /// Начинает безымянную логическую операцию.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
169 /// </summary>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
170 public void StartLogicalOperation() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
171 StartLogicalOperation(null);
313f708a50e9 improved log concept
cin
parents:
diff changeset
172 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
173
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
174 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
175 /// Начинает логическую операцию с указанным именем. Созданная операция будет добвалена в стек логических операций контекста, затем будет создано соответсвующее событие.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
176 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
177 /// <param name="name">Имя начинаемой операции.</param>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
178 public void StartLogicalOperation(string name) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
179 m_currentOperation = new LogicalOperation(name, m_currentOperation);
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
180 LogEvent(TraceEventType.OperationStarted, name);
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
181 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
182
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
183 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
184 /// Заканчивает логическую операцию начатую в текущем контексте. Операции, начатые в других контекстах не могут быть закончены в текущем контексте.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
185 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
186 /// <remarks>
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
187 /// При вызове данного метода создается событие журнала трассировки, либо о завершении операции, либо об ошибки, поскольку данная операция
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
188 /// начата в другом контексте.
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
189 /// </remarks>
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
190 public void EndLogicalOperation() {
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
191 if (m_bound == m_currentOperation) {
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
192 LogEvent(TraceEventType.Error, "Trying to end the operation which isn't belongs to current trace");
313f708a50e9 improved log concept
cin
parents:
diff changeset
193 } else {
313f708a50e9 improved log concept
cin
parents:
diff changeset
194 var op = m_currentOperation;
40
fe33f4e02ad5 improved tracing
cin
parents: 37
diff changeset
195 LogEvent(TraceEventType.OperationCompleted, "{0} {1} ms", op.Name, op.Duration);
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
196 m_currentOperation = m_currentOperation.Parent;
313f708a50e9 improved log concept
cin
parents:
diff changeset
197 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
198 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
199
43
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
200 /// <summary>
52
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
201 /// Создает копию контекста и возвращается на предыдущую операцию в текущем контексте, это позволяет начать операцию в одном потоке, а завершить - в другом.
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
202 /// </summary>
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
203 /// <returns>Контекст трассировки, который можно присоединить к другому потоку.</returns>
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
204 public TraceContext DetachLogicalOperation() {
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
205 if (m_bound == m_currentOperation) {
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
206 return new TraceContext();
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
207 } else {
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
208 var detached = new TraceContext(this, true);
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
209 m_currentOperation = m_currentOperation.Parent;
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
210 return detached;
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
211 }
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
212 }
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
213
66
790e8a997d30 Refactoring
cin
parents: 52
diff changeset
214 public void BindLogicalOperationToPromise(IPromise promise) {
52
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
215 Safe.ArgumentNotNull(promise, "promise");
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
216
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
217 var ctx = DetachLogicalOperation();
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
218 promise.Finally(() => {
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
219 var old = _current;
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
220 TraceContext.Attach(ctx);
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
221 TraceContext.Current.EndLogicalOperation();
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
222 _current = old;
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
223 });
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
224 }
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
225
edf0bc558596 improved trace system
cin
parents: 48
diff changeset
226 /// <summary>
43
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
227 /// Заврешает все начатые в этом контексте операции
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
228 /// </summary>
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
229 public void EndAllOperations() {
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
230 while (m_bound != m_currentOperation)
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
231 EndLogicalOperation();
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
232 }
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 41
diff changeset
233
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
234 void LogEvent(TraceEventType type, string format, params object[] args) {
37
c2c043520724 working version of diagnostics logging
cin
parents: 36
diff changeset
235 LogChannel<TraceEvent>.Default.LogEvent(this, TraceEvent.Create(type, format, args));
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
236 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
237 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
238 }