annotate Implab/Diagnostics/TraceEvent.cs @ 65:653c4e04968b

minor changes
author cin
date Mon, 30 Jun 2014 13:55:22 +0400
parents edf0bc558596
children dc4942d09e74
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.Linq;
313f708a50e9 improved log concept
cin
parents:
diff changeset
4 using System.Text;
313f708a50e9 improved log concept
cin
parents:
diff changeset
5
313f708a50e9 improved log concept
cin
parents:
diff changeset
6 namespace Implab.Diagnostics {
313f708a50e9 improved log concept
cin
parents:
diff changeset
7 public class TraceEvent {
313f708a50e9 improved log concept
cin
parents:
diff changeset
8 public string Message {
313f708a50e9 improved log concept
cin
parents:
diff changeset
9 get;
313f708a50e9 improved log concept
cin
parents:
diff changeset
10 private set;
313f708a50e9 improved log concept
cin
parents:
diff changeset
11 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
12
313f708a50e9 improved log concept
cin
parents:
diff changeset
13 public TraceEventType EventType {
313f708a50e9 improved log concept
cin
parents:
diff changeset
14 get;
313f708a50e9 improved log concept
cin
parents:
diff changeset
15 private set;
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 public TraceEvent(TraceEventType type, string message) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
19 EventType = type;
313f708a50e9 improved log concept
cin
parents:
diff changeset
20 Message = message;
313f708a50e9 improved log concept
cin
parents:
diff changeset
21 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
22
40
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
23 public override string ToString() {
52
edf0bc558596 improved trace system
cin
parents: 43
diff changeset
24 if (EventType == TraceEventType.Information)
edf0bc558596 improved trace system
cin
parents: 43
diff changeset
25 return Message;
edf0bc558596 improved trace system
cin
parents: 43
diff changeset
26 else
edf0bc558596 improved trace system
cin
parents: 43
diff changeset
27 return String.Format("{0}: {1}", EventType, Message);
40
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
28 }
fe33f4e02ad5 improved tracing
cin
parents: 36
diff changeset
29
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
30 public static TraceEvent Create(TraceEventType type, string format, params object[] args) {
43
7c2369f580b8 improved tracing, TextListenerBase can be bound to logical operation scope.
cin
parents: 42
diff changeset
31 return new TraceEvent(type, format == null ? String.Empty : String.Format(format, args));
36
313f708a50e9 improved log concept
cin
parents:
diff changeset
32 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
33 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
34 }