annotate Implab/Diagnostics/TraceLog.cs @ 88:c4877ae77cee v2

ServiceLocator: fixed services cleanup
author cin
date Tue, 07 Oct 2014 10:58:38 +0400
parents 790e8a997d30
children 4c0e5ef99986
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.Diagnostics;
313f708a50e9 improved log concept
cin
parents:
diff changeset
4 using System.Linq;
313f708a50e9 improved log concept
cin
parents:
diff changeset
5 using System.Text;
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 {
313f708a50e9 improved log concept
cin
parents:
diff changeset
9 /// <summary>
40
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
10 /// Класс для публикации событий выполнения программы, события публикуются через <see cref="LogChannel{TraceEvent}"/>.
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
11 /// Журнал трассировки отражает логический ход выполнения программы и существует всегда, поскольку тесно связан с
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
12 /// контекстом трассировки.
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
13 /// </summary>
313f708a50e9 improved log concept
cin
parents:
diff changeset
14 public static class TraceLog {
313f708a50e9 improved log concept
cin
parents:
diff changeset
15 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
16 public static void StartLogicalOperation() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
17 TraceContext.Current.StartLogicalOperation();
313f708a50e9 improved log concept
cin
parents:
diff changeset
18 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
19
313f708a50e9 improved log concept
cin
parents:
diff changeset
20 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
21 public static void StartLogicalOperation(string name) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
22 TraceContext.Current.StartLogicalOperation(name);
313f708a50e9 improved log concept
cin
parents:
diff changeset
23 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
24
313f708a50e9 improved log concept
cin
parents:
diff changeset
25 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
26 public static void EndLogicalOperation() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
27 TraceContext.Current.EndLogicalOperation();
313f708a50e9 improved log concept
cin
parents:
diff changeset
28 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
29
313f708a50e9 improved log concept
cin
parents:
diff changeset
30 [Conditional("TRACE")]
66
790e8a997d30 Refactoring
cin
parents: 52
diff changeset
31 public static void BindLogicalOperationToPromise(IPromise promise) {
52
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
32 TraceContext.Current.BindLogicalOperationToPromise(promise);
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
33 }
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
34
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
35 [Conditional("TRACE")]
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
36 public static void TraceInformation(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
37 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
38 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
39
313f708a50e9 improved log concept
cin
parents:
diff changeset
40 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
41 public static void TraceWarning(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
42 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
43 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
44
313f708a50e9 improved log concept
cin
parents:
diff changeset
45 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
46 public static void TraceError(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
47 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Error, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
48 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
49
313f708a50e9 improved log concept
cin
parents:
diff changeset
50 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
51 public static void TraceError(Exception err) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
52 TraceError("{0}", err);
313f708a50e9 improved log concept
cin
parents:
diff changeset
53 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
54 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
55 }