IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
DiagnosticEventSource.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics.Tracing;
3
5{
6
10 [EventSource(Name = "IKVM")]
11 unsafe partial class DiagnosticEventSource : EventSource, IDiagnosticHandler
12 {
13
18
22 DiagnosticEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat | EventSourceSettings.ThrowOnEventWriteErrors)
23 {
24
25 }
26
28 [NonEvent]
30 {
31 return IsEnabled(ToLevel(diagnostic.Level), EventKeywords.All);
32 }
33
40 [NonEvent]
41 EventLevel ToLevel(DiagnosticLevel level)
42 {
43 return level switch
44 {
45 DiagnosticLevel.Trace => EventLevel.Verbose,
46 DiagnosticLevel.Info => EventLevel.Informational,
47 DiagnosticLevel.Warning => EventLevel.Warning,
48 DiagnosticLevel.Error => EventLevel.Error,
49 DiagnosticLevel.Fatal => EventLevel.Critical,
50 _ => throw new NotImplementedException()
51 };
52 }
53
54 [NonEvent]
55 void WriteEvent(int eventId, string arg0, string arg1, string arg2, string arg3)
56 {
57 arg0 ??= "";
58 arg1 ??= "";
59 arg2 ??= "";
60 arg3 ??= "";
61
62 fixed (char* arg0Ptr = arg0)
63 fixed (char* arg1Ptr = arg1)
64 fixed (char* arg2Ptr = arg2)
65 fixed (char* arg3Ptr = arg3)
66 {
67 var ptr = stackalloc EventData[4];
68 ptr[0].DataPointer = (IntPtr)arg0Ptr;
69 ptr[0].Size = (arg0.Length + 1) * 2;
70 ptr[1].DataPointer = (IntPtr)arg1Ptr;
71 ptr[1].Size = (arg1.Length + 1) * 2;
72 ptr[2].DataPointer = (IntPtr)arg2Ptr;
73 ptr[2].Size = (arg2.Length + 1) * 2;
74 ptr[3].DataPointer = (IntPtr)arg3Ptr;
75 ptr[3].Size = (arg3.Length + 1) * 2;
76 WriteEventCore(eventId, 4, ptr);
77 }
78 }
79
80 }
81
82}
global::java.lang.invoke.LambdaForm.Name Name
Provides a EventSource to receive emitted IKVM diagnostic messages.
static readonly DiagnosticEventSource Instance
Gets the default instance of this event source.
Exposes methods to accept diagnostic invocations.
bool IsEnabled(Diagnostic diagnostic)
Returns true if the specified Diagnostic is enabled.
DiagnosticLevel
Represents the level of security of a diagnostic event.