annotate Implab/Diagnostics/TraceEvent.cs @ 228:6fa235c5a760 v2

Rewritten JsonScanner, JsonParser, fixed naming style
author cin
date Tue, 12 Sep 2017 01:19:12 +0300
parents cc1baf7c8bd9
children
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
313f708a50e9 improved log concept
cin
parents:
diff changeset
3 namespace Implab.Diagnostics {
313f708a50e9 improved log concept
cin
parents:
diff changeset
4 public class TraceEvent {
313f708a50e9 improved log concept
cin
parents:
diff changeset
5 public string Message {
313f708a50e9 improved log concept
cin
parents:
diff changeset
6 get;
313f708a50e9 improved log concept
cin
parents:
diff changeset
7 private set;
313f708a50e9 improved log concept
cin
parents:
diff changeset
8 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
9
313f708a50e9 improved log concept
cin
parents:
diff changeset
10 public TraceEventType EventType {
313f708a50e9 improved log concept
cin
parents:
diff changeset
11 get;
313f708a50e9 improved log concept
cin
parents:
diff changeset
12 private set;
313f708a50e9 improved log concept
cin
parents:
diff changeset
13 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
14
195
ea485487a424 minor changes
cin
parents: 133
diff changeset
15 /// <summary>
ea485487a424 minor changes
cin
parents: 133
diff changeset
16 /// The logical operation this event belongs to.
ea485487a424 minor changes
cin
parents: 133
diff changeset
17 /// </summary>
ea485487a424 minor changes
cin
parents: 133
diff changeset
18 public LogicalOperation Operation {
ea485487a424 minor changes
cin
parents: 133
diff changeset
19 get;
ea485487a424 minor changes
cin
parents: 133
diff changeset
20 private set;
ea485487a424 minor changes
cin
parents: 133
diff changeset
21 }
ea485487a424 minor changes
cin
parents: 133
diff changeset
22
ea485487a424 minor changes
cin
parents: 133
diff changeset
23 /// <summary>
ea485487a424 minor changes
cin
parents: 133
diff changeset
24 /// Gets the time offset in milliseconds from the start of the operation, if the operation is not specified the value is zero.
ea485487a424 minor changes
cin
parents: 133
diff changeset
25 /// </summary>
ea485487a424 minor changes
cin
parents: 133
diff changeset
26 public int OperationTime {
ea485487a424 minor changes
cin
parents: 133
diff changeset
27 get;
ea485487a424 minor changes
cin
parents: 133
diff changeset
28 private set;
ea485487a424 minor changes
cin
parents: 133
diff changeset
29 }
ea485487a424 minor changes
cin
parents: 133
diff changeset
30
ea485487a424 minor changes
cin
parents: 133
diff changeset
31 public TraceEvent(LogicalOperation operation, TraceEventType type, string message) {
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
32 EventType = type;
313f708a50e9 improved log concept
cin
parents:
diff changeset
33 Message = message;
195
ea485487a424 minor changes
cin
parents: 133
diff changeset
34 Operation = operation;
ea485487a424 minor changes
cin
parents: 133
diff changeset
35 if (operation != null)
ea485487a424 minor changes
cin
parents: 133
diff changeset
36 OperationTime = operation.Duration;
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
37 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
38
40
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
39 public override string ToString() {
133
cin
parents: 93
diff changeset
40 return Message;
40
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
41 }
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
42
195
ea485487a424 minor changes
cin
parents: 133
diff changeset
43 public static TraceEvent Create(LogicalOperation operation, TraceEventType type, string format, params object[] args) {
219
cc1baf7c8bd9 fixed trace
cin
parents: 195
diff changeset
44 return new TraceEvent(operation, type, format == null ? String.Empty : args == null || args.Length == 0 ? format : String.Format(format, args));
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
45 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
46 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
47 }