comparison Implab/Diagnostics/Trace.cs @ 252:6f4630d0bcd9 v3

removed absolete Diagnostics classes
author cin
date Mon, 12 Feb 2018 07:24:31 +0300
parents babe55c34931
children 34df34841225
comparison
equal deleted inserted replaced
251:7c7e9ad6fe4a 252:6f4630d0bcd9
6 using System.Threading.Tasks; 6 using System.Threading.Tasks;
7 7
8 namespace Implab.Diagnostics { 8 namespace Implab.Diagnostics {
9 public static class Trace<T> { 9 public static class Trace<T> {
10 10
11 readonly static LogChannel<TraceEvent> _channel = new LogChannel<TraceEvent>(typeof(T).Name); 11 readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name);
12 12
13 public static LogChannel<TraceEvent> Channel { 13 public static TraceSource TraceSource {
14 get { return _channel; } 14 get { return _traceSource; }
15 } 15 }
16 16
17 /// <summary> 17 /// <summary>
18 /// Starts the logical operation nested to the current operation nested to the current one. 18 /// Starts the logical operation nested to the current operation nested to the current one.
19 /// </summary> 19 /// </summary>
20 [Conditional("TRACE")] 20 [Conditional("TRACE")]
21 public static void StartLogicalOperation() { 21 public static void StartLogicalOperation() {
22 TraceContext.Instance.StartLogicalOperation(); 22 Trace.CorrelationManager.StartLogicalOperation();
23 23
24 } 24 }
25 25
26 /// <summary> 26 /// <summary>
27 /// Starts the logical operation with the specified name, this name is usefull in logs. 27 /// Starts the logical operation with the specified name, this name is usefull in logs.
28 /// </summary> 28 /// </summary>
29 /// <param name="name">Name.</param> 29 /// <param name="name">Name.</param>
30 [Conditional("TRACE")] 30 [Conditional("TRACE")]
31 public static void StartLogicalOperation(string name) { 31 public static void StartLogicalOperation(string name) {
32 Channel.LogEvent(new TraceEvent(TraceContext.Instance.CurrentOperation, TraceEventType.OperationStarted, name)); 32 Trace.CorrelationManager.StartLogicalOperation();
33 TraceContext.Instance.StartLogicalOperation(name);
34 } 33 }
35 34
36 /// <summary> 35 /// <summary>
37 /// Ends the logical operation and restores the previous one. 36 /// Ends the logical operation and restores the previous one.
38 /// </summary> 37 /// </summary>
39 [Conditional("TRACE")] 38 [Conditional("TRACE")]
40 public static void EndLogicalOperation() { 39 public static void StopLogicalOperation() {
41 var op = TraceContext.Instance.EndLogicalOperation(); 40 Trace.CorrelationManager.StopLogicalOperation();
42 Channel.LogEvent(new TraceEvent(op, TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms", op.Name, op.Duration)));
43 } 41 }
44 42
45 /// <summary> 43 /// <summary>
46 /// Writes an informational message. 44 /// Writes an informational message.
47 /// </summary> 45 /// </summary>
48 /// <param name="format">Format.</param> 46 /// <param name="format">Format.</param>
49 /// <param name="arguments">Arguments.</param> 47 /// <param name="arguments">Arguments.</param>
50 [Conditional("TRACE")] 48 [Conditional("TRACE")]
51 public static void Log(string format, params object[] arguments) { 49 public static void Log(string format, params object[] arguments) {
52 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Information, format, arguments)); 50 TraceSource.TraceEvent(TraceEventType.Information, 1, format, arguments);
53 } 51 }
54 52
55 /// <summary> 53 /// <summary>
56 /// Writes a warning message. 54 /// Writes a warning message.
57 /// </summary> 55 /// </summary>
58 /// <param name="format">Format.</param> 56 /// <param name="format">Format.</param>
59 /// <param name="arguments">Arguments.</param> 57 /// <param name="arguments">Arguments.</param>
60 [Conditional("TRACE")] 58 [Conditional("TRACE")]
61 public static void Warn(string format, params object[] arguments) { 59 public static void Warn(string format, params object[] arguments) {
62 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Warning, format, arguments)); 60 TraceSource.TraceEvent(TraceEventType.Warning, 1, format, arguments);
63 } 61 }
64 62
65 [Conditional("TRACE")] 63 [Conditional("TRACE")]
66 public static void Error(string format, params object[] arguments) { 64 public static void Error(string format, params object[] arguments) {
67 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Error, format, arguments)); 65 TraceSource.TraceEvent(TraceEventType.Error, 1, format, arguments);
68 } 66 }
69 67
70 [Conditional("TRACE")] 68 [Conditional("TRACE")]
71 public static void Error(Exception err) { 69 public static void Error(Exception err) {
72 Error("{0}", err); 70 TraceSource.TraceData(TraceEventType.Error, 1, err);
73 } 71 }
74 } 72 }
75 } 73 }