-
Notifications
You must be signed in to change notification settings - Fork 2k
/
TraceTelemetryConsumer.cs
59 lines (53 loc) · 1.87 KB
/
TraceTelemetryConsumer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections.Generic;
using System.Diagnostics;
namespace Orleans.Runtime
{
public class TraceTelemetryConsumer : ITraceTelemetryConsumer
{
public void TrackTrace(string message)
{
Trace.TraceInformation(message);
}
public void TrackTrace(string message, IDictionary<string, string> properties)
{
TrackTrace(TraceParserUtils.PrintProperties(message, properties));
}
public void TrackTrace(string message, Severity severity)
{
switch (severity)
{
case Severity.Error:
Trace.TraceError(message);
break;
case Severity.Info:
Trace.TraceInformation(message);
break;
case Severity.Verbose:
case Severity.Verbose2:
case Severity.Verbose3:
Trace.WriteLine(message);
break;
case Severity.Warning:
Trace.TraceWarning(message);
break;
case Severity.Off:
return;
}
Trace.Flush();
}
public void TrackTrace(string message, Severity severity, IDictionary<string, string> properties)
{
TrackTrace(TraceParserUtils.PrintProperties(message, properties), severity);
}
public void Flush()
{
Trace.Flush();
}
public void Close()
{
// We are not closing Trace here, since Orleans does not own the configured TraceListeners.
// Closing here cause a possible failure for any further Trace method calls outside of Orleans too,
// which can lead to unpredicted results, like in case of Azure an ObjectDisposedException.
}
}
}