comparison Implab/Diagnostics/TraceLog.cs @ 195:ea485487a424 v2

minor changes
author cin
date Wed, 04 May 2016 12:28:08 +0300
parents 4c0e5ef99986
children 71e543dbe65a
comparison
equal deleted inserted replaced
194:d45bdf510514 195:ea485487a424
5 using System.Text; 5 using System.Text;
6 using System.Threading.Tasks; 6 using System.Threading.Tasks;
7 7
8 namespace Implab.Diagnostics { 8 namespace Implab.Diagnostics {
9 /// <summary> 9 /// <summary>
10 /// Класс для публикации событий выполнения программы, события публикуются через <see cref="LogChannel{TraceEvent}"/>. 10 /// This class is used to trace a logical flow of the application, it publishes events to the default <see cref="TraceEvent"/> channel.
11 /// Журнал трассировки отражает логический ход выполнения программы и существует всегда, поскольку тесно связан с
12 /// контекстом трассировки.
13 /// </summary> 11 /// </summary>
14 public static class TraceLog { 12 public static class TraceLog {
13 /// <summary>
14 /// Starts the logical operation nested to the current operation nested to the current one.
15 /// </summary>
15 [Conditional("TRACE")] 16 [Conditional("TRACE")]
16 public static void StartLogicalOperation() { 17 public static void StartLogicalOperation() {
17 TraceContext.Instance.StartLogicalOperation(); 18 TraceContext.Instance.StartLogicalOperation();
19
18 } 20 }
19 21
22 /// <summary>
23 /// Starts the logical operation with the specified name, this name is usefull in logs.
24 /// </summary>
25 /// <param name="name">Name.</param>
20 [Conditional("TRACE")] 26 [Conditional("TRACE")]
21 public static void StartLogicalOperation(string name) { 27 public static void StartLogicalOperation(string name) {
22 TraceContext.Instance.StartLogicalOperation(name); 28 TraceContext.Instance.StartLogicalOperation(name);
23 } 29 }
24 30
31 /// <summary>
32 /// Ends the logical operation and restores the previous one.
33 /// </summary>
25 [Conditional("TRACE")] 34 [Conditional("TRACE")]
26 public static void EndLogicalOperation() { 35 public static void EndLogicalOperation() {
27 TraceContext.Instance.EndLogicalOperation(); 36 var op = TraceContext.Instance.EndLogicalOperation();
37 LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms",op.Name, op.Duration)));
28 } 38 }
29 39
40 /// <summary>
41 /// Writes an informational message.
42 /// </summary>
43 /// <param name="format">Format.</param>
44 /// <param name="arguments">Arguments.</param>
30 [Conditional("TRACE")] 45 [Conditional("TRACE")]
31 public static void TraceInformation(string format, params object[] arguments) { 46 public static void TraceInformation(string format, params object[] arguments) {
32 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments)); 47 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments));
33 } 48 }
34 49
50 /// <summary>
51 /// Writes a warning message.
52 /// </summary>
53 /// <param name="format">Format.</param>
54 /// <param name="arguments">Arguments.</param>
35 [Conditional("TRACE")] 55 [Conditional("TRACE")]
36 public static void TraceWarning(string format, params object[] arguments) { 56 public static void TraceWarning(string format, params object[] arguments) {
37 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, format, arguments)); 57 LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, format, arguments));
38 } 58 }
39 59