annotate Implab/Diagnostics/TraceLog.cs @ 192:f1da3afc3521 release v2.1

Слияние с v2
author cin
date Fri, 22 Apr 2016 13:10:34 +0300
parents 4c0e5ef99986
children ea485487a424
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() {
92
4c0e5ef99986 rewritten tracing
cin
parents: 66
diff changeset
17 TraceContext.Instance.StartLogicalOperation();
36
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) {
92
4c0e5ef99986 rewritten tracing
cin
parents: 66
diff changeset
22 TraceContext.Instance.StartLogicalOperation(name);
36
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() {
92
4c0e5ef99986 rewritten tracing
cin
parents: 66
diff changeset
27 TraceContext.Instance.EndLogicalOperation();
52
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
28 }
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
29
edf0bc558596 improved trace system
cin
parents: 40
diff changeset
30 [Conditional("TRACE")]
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
31 public static void TraceInformation(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
32 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments));
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 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
36 public static void TraceWarning(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
37 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, 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 TraceError(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
42 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Error, 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(Exception err) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
47 TraceError("{0}", err);
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 }