annotate Implab/Diagnostics/LogChannel.cs @ 36:313f708a50e9 diagnostics

improved log concept
author cin
date Tue, 15 Apr 2014 02:00:09 +0400
parents
children c2c043520724
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 LogChannel<TEvent> {
313f708a50e9 improved log concept
cin
parents:
diff changeset
8 static LogChannel<TEvent> _default = new LogChannel<TEvent>();
313f708a50e9 improved log concept
cin
parents:
diff changeset
9
313f708a50e9 improved log concept
cin
parents:
diff changeset
10 public static LogChannel<TEvent> Default {
313f708a50e9 improved log concept
cin
parents:
diff changeset
11 get {
313f708a50e9 improved log concept
cin
parents:
diff changeset
12 return _default;
313f708a50e9 improved log concept
cin
parents:
diff changeset
13 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
14 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
15
313f708a50e9 improved log concept
cin
parents:
diff changeset
16 public event EventHandler<ValueEventArgs<TEvent>> Events;
313f708a50e9 improved log concept
cin
parents:
diff changeset
17
313f708a50e9 improved log concept
cin
parents:
diff changeset
18 public void LogEvent(TEvent data) {
313f708a50e9 improved log concept
cin
parents:
diff changeset
19 var t = Events;
313f708a50e9 improved log concept
cin
parents:
diff changeset
20 if (t!= null)
313f708a50e9 improved log concept
cin
parents:
diff changeset
21 t(TraceContext.Current,new ValueEventArgs<TEvent>(data));
313f708a50e9 improved log concept
cin
parents:
diff changeset
22 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
23 }
313f708a50e9 improved log concept
cin
parents:
diff changeset
24 }