36
|
1 using System;
|
|
2
|
|
3 namespace Implab.Diagnostics {
|
|
4 public class TraceEvent {
|
|
5 public string Message {
|
|
6 get;
|
|
7 private set;
|
|
8 }
|
|
9
|
|
10 public TraceEventType EventType {
|
|
11 get;
|
|
12 private set;
|
|
13 }
|
|
14
|
195
|
15 /// <summary>
|
|
16 /// The logical operation this event belongs to.
|
|
17 /// </summary>
|
|
18 public LogicalOperation Operation {
|
|
19 get;
|
|
20 private set;
|
|
21 }
|
|
22
|
|
23 /// <summary>
|
|
24 /// Gets the time offset in milliseconds from the start of the operation, if the operation is not specified the value is zero.
|
|
25 /// </summary>
|
|
26 public int OperationTime {
|
|
27 get;
|
|
28 private set;
|
|
29 }
|
|
30
|
|
31 public TraceEvent(LogicalOperation operation, TraceEventType type, string message) {
|
36
|
32 EventType = type;
|
|
33 Message = message;
|
195
|
34 Operation = operation;
|
|
35 if (operation != null)
|
|
36 OperationTime = operation.Duration;
|
36
|
37 }
|
|
38
|
40
|
39 public override string ToString() {
|
133
|
40 return Message;
|
40
|
41 }
|
|
42
|
195
|
43 public static TraceEvent Create(LogicalOperation operation, TraceEventType type, string format, params object[] args) {
|
|
44 return new TraceEvent(operation, type, format == null ? String.Empty : String.Format(format, args));
|
36
|
45 }
|
|
46 }
|
|
47 }
|