annotate Implab/Diagnostics/TraceLog.cs @ 38:1cedc4e58acc diagnostics

Закрыть ветку diagnostics
author cin
date Tue, 15 Apr 2014 02:46:33 +0400
parents 313f708a50e9
children fe33f4e02ad5
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>
313f708a50e9 improved log concept
cin
parents:
diff changeset
10 /// Класс для публикации событий выполнения программы, события публикуются через <see cref="LogChannel{TraceEvent}"/>
313f708a50e9 improved log concept
cin
parents:
diff changeset
11 /// </summary>
313f708a50e9 improved log concept
cin
parents:
diff changeset
12 public static class TraceLog {
313f708a50e9 improved log concept
cin
parents:
diff changeset
13 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
14 public static void Transfer(TraceContext from) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
15 TraceContext.Transfer(from);
313f708a50e9 improved log concept
cin
parents:
diff changeset
16 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
17
313f708a50e9 improved log concept
cin
parents:
diff changeset
18 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
19 public static void StartLogicalOperation() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
20 TraceContext.Current.StartLogicalOperation();
313f708a50e9 improved log concept
cin
parents:
diff changeset
21 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
22
313f708a50e9 improved log concept
cin
parents:
diff changeset
23 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
24 public static void StartLogicalOperation(string name) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
25 TraceContext.Current.StartLogicalOperation(name);
313f708a50e9 improved log concept
cin
parents:
diff changeset
26 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
27
313f708a50e9 improved log concept
cin
parents:
diff changeset
28 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
29 public static void EndLogicalOperation() {
313f708a50e9 improved log concept
cin
parents:
diff changeset
30 TraceContext.Current.EndLogicalOperation();
313f708a50e9 improved log concept
cin
parents:
diff changeset
31 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
32
313f708a50e9 improved log concept
cin
parents:
diff changeset
33 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
34 public static void TraceInformation(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
35 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
36 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
37
313f708a50e9 improved log concept
cin
parents:
diff changeset
38 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
39 public static void TraceWarning(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
40 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
41 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
42
313f708a50e9 improved log concept
cin
parents:
diff changeset
43 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
44 public static void TraceError(string format, params object[] arguments) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
45 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Error, format, arguments));
313f708a50e9 improved log concept
cin
parents:
diff changeset
46 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
47
313f708a50e9 improved log concept
cin
parents:
diff changeset
48 [Conditional("TRACE")]
313f708a50e9 improved log concept
cin
parents:
diff changeset
49 public static void TraceError(Exception err) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
50 TraceError("{0}", err);
313f708a50e9 improved log concept
cin
parents:
diff changeset
51 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
52 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
53 }