| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.Runtime.Diagnostics |
| | | 7 | | { |
| | | 8 | | internal sealed class EtwDiagnosticTrace |
| | | 9 | | { |
| | 6 | 10 | | public static readonly Guid ImmutableDefaultEtwProviderId = new Guid("{c651f5f6-1c0d-492e-8ae1-b4efd7c9d503}"); |
| | 6 | 11 | | private static Guid s_defaultEtwProviderId = ImmutableDefaultEtwProviderId; |
| | | 12 | | |
| | | 13 | | public static Guid DefaultEtwProviderId |
| | | 14 | | { |
| | | 15 | | get |
| | | 16 | | { |
| | 8 | 17 | | return s_defaultEtwProviderId; |
| | | 18 | | } |
| | | 19 | | set |
| | | 20 | | { |
| | 0 | 21 | | s_defaultEtwProviderId = value; |
| | 0 | 22 | | } |
| | | 23 | | } |
| | | 24 | | |
| | 8 | 25 | | public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId) |
| | | 26 | | //: base(traceSourceName) |
| | | 27 | | { |
| | | 28 | | // try |
| | | 29 | | // { |
| | | 30 | | // this.TraceSourceName = traceSourceName; |
| | | 31 | | // this.EventSourceName = string.Concat(this.TraceSourceName, " ", EventSourceVersion); |
| | | 32 | | // CreateTraceSource(); |
| | | 33 | | // } |
| | | 34 | | // catch (Exception exception) |
| | | 35 | | // { |
| | | 36 | | // if (Fx.IsFatal(exception)) |
| | | 37 | | // { |
| | | 38 | | // throw; |
| | | 39 | | // } |
| | | 40 | | |
| | | 41 | | //#pragma warning disable 618 |
| | | 42 | | // EventLogger logger = new EventLogger(this.EventSourceName, null); |
| | | 43 | | // logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagno |
| | | 44 | | // exception.ToString()); |
| | | 45 | | //#pragma warning restore 618 |
| | | 46 | | // } |
| | | 47 | | |
| | | 48 | | // try |
| | | 49 | | // { |
| | | 50 | | // CreateEtwProvider(etwProviderId); |
| | | 51 | | // } |
| | | 52 | | // catch (Exception exception) |
| | | 53 | | // { |
| | | 54 | | // if (Fx.IsFatal(exception)) |
| | | 55 | | // { |
| | | 56 | | // throw; |
| | | 57 | | // } |
| | | 58 | | |
| | | 59 | | // this.etwProvider = null; |
| | | 60 | | //#pragma warning disable 618 |
| | | 61 | | // EventLogger logger = new EventLogger(this.EventSourceName, null); |
| | | 62 | | // logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagno |
| | | 63 | | // exception.ToString()); |
| | | 64 | | //#pragma warning restore 618 |
| | | 65 | | |
| | | 66 | | // } |
| | | 67 | | |
| | | 68 | | // if (this.TracingEnabled || this.EtwTracingEnabled) |
| | | 69 | | // { |
| | | 70 | | //#pragma warning disable 618 |
| | | 71 | | // this.AddDomainEventHandlersForCleanup(); |
| | | 72 | | //#pragma warning restore 618 |
| | | 73 | | // } |
| | 8 | 74 | | } |
| | | 75 | | } |
| | | 76 | | } |