diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs
index 43d9d051b9ea6..d99bd95f4ddbe 100644
--- a/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs
+++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SSPIWrapper.cs
@@ -118,7 +118,7 @@ public static unsafe SafeFreeCredentials AcquireCredentialsHandle(ISSPIInterface
if (errorCode != 0)
{
- if (NetEventSource.IsEnabled) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
+ if (NetEventSource.Log.IsEnabled()) NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
throw new Win32Exception(errorCode);
}
diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs
index b69d62803b3ad..76539c89247c6 100644
--- a/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs
+++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs
@@ -307,7 +307,7 @@ public static unsafe int AcquireCredentialsHandle(
ref outCredential._handle,
out timeStamp);
- if (NetEventSource.IsEnabled) NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
+ if (NetEventSource.Log.IsEnabled()) NetEventSource.Verbose(null, $"{nameof(Interop.SspiCli.AcquireCredentialsHandleW)} returns 0x{errorCode:x}, handle = {outCredential}");
if (errorCode != 0)
{
diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/NetEventSource.Common.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/NetEventSource.Common.cs
index 174ad40e273d4..6905c66e6dbff 100644
--- a/src/libraries/Common/src/System/Net/Http/aspnetcore/NetEventSource.Common.cs
+++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/NetEventSource.Common.cs
@@ -95,7 +95,7 @@ public static void Enter(object? thisOrContextObject, FormattableString? formatt
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(formattableString);
- if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
+ if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
}
/// Logs entrance to a method.
@@ -107,7 +107,7 @@ public static void Enter(object? thisOrContextObject, object arg0, [CallerMember
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(arg0);
- if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})");
+ if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)})");
}
/// Logs entrance to a method.
@@ -121,7 +121,7 @@ public static void Enter(object? thisOrContextObject, object arg0, object arg1,
DebugValidateArg(thisOrContextObject);
DebugValidateArg(arg0);
DebugValidateArg(arg1);
- if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})");
+ if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)})");
}
/// Logs entrance to a method.
@@ -137,7 +137,7 @@ public static void Enter(object? thisOrContextObject, object arg0, object arg1,
DebugValidateArg(arg0);
DebugValidateArg(arg1);
DebugValidateArg(arg2);
- if (IsEnabled) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})");
+ if (Log.IsEnabled()) Log.Enter(IdOf(thisOrContextObject), memberName, $"({Format(arg0)}, {Format(arg1)}, {Format(arg2)})");
}
[Event(EnterEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)]
@@ -155,7 +155,7 @@ public static void Exit(object? thisOrContextObject, FormattableString? formatta
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(formattableString);
- if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
+ if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
}
/// Logs exit from a method.
@@ -167,7 +167,7 @@ public static void Exit(object? thisOrContextObject, object arg0, [CallerMemberN
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(arg0);
- if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString());
+ if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, Format(arg0).ToString());
}
/// Logs exit from a method.
@@ -181,7 +181,7 @@ public static void Exit(object? thisOrContextObject, object arg0, object arg1, [
DebugValidateArg(thisOrContextObject);
DebugValidateArg(arg0);
DebugValidateArg(arg1);
- if (IsEnabled) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}");
+ if (Log.IsEnabled()) Log.Exit(IdOf(thisOrContextObject), memberName, $"{Format(arg0)}, {Format(arg1)}");
}
[Event(ExitEventId, Level = EventLevel.Informational, Keywords = Keywords.EnterExit)]
@@ -199,7 +199,7 @@ public static void Info(object? thisOrContextObject, FormattableString? formatta
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(formattableString);
- if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
+ if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
}
/// Logs an information message.
@@ -211,7 +211,7 @@ public static void Info(object? thisOrContextObject, object? message, [CallerMem
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(message);
- if (IsEnabled) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString());
+ if (Log.IsEnabled()) Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString());
}
[Event(InfoEventId, Level = EventLevel.Informational, Keywords = Keywords.Default)]
@@ -229,7 +229,7 @@ public static void Error(object? thisOrContextObject, FormattableString formatta
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(formattableString);
- if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString));
+ if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString));
}
/// Logs an error message.
@@ -241,7 +241,7 @@ public static void Error(object? thisOrContextObject, object message, [CallerMem
{
DebugValidateArg(thisOrContextObject);
DebugValidateArg(message);
- if (IsEnabled) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString());
+ if (Log.IsEnabled()) Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString());
}
[Event(ErrorEventId, Level = EventLevel.Error, Keywords = Keywords.Default)]
@@ -269,7 +269,7 @@ public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, [Calle
[NonEvent]
public static void DumpBuffer(object? thisOrContextObject, byte[] buffer, int offset, int count, [CallerMemberName] string? memberName = null)
{
- if (IsEnabled && offset >= 0 && offset <= buffer.Length - count)
+ if (Log.IsEnabled() && offset >= 0 && offset <= buffer.Length - count)
{
count = Math.Min(count, MaxDumpSize);
@@ -295,7 +295,7 @@ public static unsafe void DumpBuffer(object? thisOrContextObject, IntPtr bufferP
Debug.Assert(bufferPtr != IntPtr.Zero);
Debug.Assert(count >= 0);
- if (IsEnabled)
+ if (Log.IsEnabled())
{
var buffer = new byte[Math.Min(count, MaxDumpSize)];
fixed (byte* targetPtr = buffer)
@@ -321,7 +321,7 @@ public static void Associate(object first, object second, [CallerMemberName] str
{
DebugValidateArg(first);
DebugValidateArg(second);
- if (IsEnabled) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second));
+ if (Log.IsEnabled()) Log.Associate(IdOf(first), memberName, IdOf(first), IdOf(second));
}
/// Logs a relationship between two objects.
@@ -335,7 +335,7 @@ public static void Associate(object? thisOrContextObject, object first, object s
DebugValidateArg(thisOrContextObject);
DebugValidateArg(first);
DebugValidateArg(second);
- if (IsEnabled) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second));
+ if (Log.IsEnabled()) Log.Associate(IdOf(thisOrContextObject), memberName, IdOf(first), IdOf(second));
}
[Event(AssociateEventId, Level = EventLevel.Informational, Keywords = Keywords.Default, Message = "[{2}]<-->[{3}]")]
@@ -348,7 +348,7 @@ private void Associate(string thisOrContextObject, string? memberName, string fi
[Conditional("DEBUG_NETEVENTSOURCE_MISUSE")]
private static void DebugValidateArg(object? arg)
{
- if (!IsEnabled)
+ if (!Log.IsEnabled())
{
Debug.Assert(!(arg is ValueType), $"Should not be passing value type {arg?.GetType()} to logging without IsEnabled check");
Debug.Assert(!(arg is FormattableString), $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled");
@@ -358,12 +358,9 @@ private static void DebugValidateArg(object? arg)
[Conditional("DEBUG_NETEVENTSOURCE_MISUSE")]
private static void DebugValidateArg(FormattableString? arg)
{
- Debug.Assert(IsEnabled || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled");
+ Debug.Assert(Log.IsEnabled() || arg == null, $"Should not be formatting FormattableString \"{arg}\" if tracing isn't enabled");
}
- public static new bool IsEnabled =>
- Log.IsEnabled();
-
[NonEvent]
public static string IdOf(object? value) => value != null ? value.GetType().Name + "#" + GetHashCode(value) : NullInstance;
diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs
index d9f03e9e073fb..eefd608dfc0e6 100644
--- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs
+++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs
@@ -743,7 +743,7 @@ private void BufferBytes(ReadOnlySpan span)
_recvBuffer.Discard(bytesRead);
- if (NetEventSource.IsEnabled)
+ if (NetEventSource.Log.IsEnabled())
{
Trace($"Received frame {frameType} of length {payloadLength}.");
}
diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs
index 3cdf343afa199..e9dd2d81851c8 100644
--- a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs
+++ b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs
@@ -412,7 +412,7 @@ public void RegisterForCancellation(CancellationToken cancellationToken)
}
}
- if (cancelResult != 0 && cancelResult != Interop.Winsock.WSA_INVALID_HANDLE && NetEventSource.IsEnabled)
+ if (cancelResult != 0 && cancelResult != Interop.Winsock.WSA_INVALID_HANDLE && NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(@this, $"GetAddrInfoExCancel returned error {cancelResult}");
}
diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs
index 0069a234b92a6..5379f1ff1ce00 100644
--- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs
+++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicStream.cs
@@ -225,7 +225,7 @@ internal override async ValueTask ReadAsync(Memory destination, Cance
throw new InvalidOperationException("Reading is not allowed on stream.");
}
- if (NetEventSource.IsEnabled)
+ if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(this, $"[{GetHashCode()}] reading into Memory of '{destination.Length}' bytes.");
}
@@ -479,7 +479,7 @@ private static uint NativeCallbackHandler(
private uint HandleEvent(ref StreamEvent evt)
{
- if (NetEventSource.IsEnabled)
+ if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(this, $"[{GetHashCode()}] handling event '{evt.Type}'.");
}
diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Windows.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Windows.cs
index 0827eca16d572..fcb84b2dda6a0 100644
--- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Windows.cs
+++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Windows.cs
@@ -62,7 +62,7 @@ private SslStreamCertificateContext(X509Certificate2 target, X509Certificate2[]
{
store.Dispose();
store = null;
- if (NetEventSource.IsEnabled)
+ if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Error(this, $"Failed to open certificate store for intermediates.");
}
diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs
index 4cba3232be530..37f3e03eee1ef 100644
--- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs
+++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs
@@ -33,7 +33,7 @@ public static SslStreamCertificateContext Create(X509Certificate2 target, X509Ce
chain.ChainPolicy.DisableCertificateDownloads = offline;
bool chainStatus = chain.Build(target);
- if (!chainStatus && NetEventSource.IsEnabled)
+ if (!chainStatus && NetEventSource.Log.IsEnabled())
{
NetEventSource.Error(null, $"Failed to build chain for {target.Subject}");
}
diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs
index 89b474fe4bf48..b93e89957bc76 100644
--- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs
+++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs
@@ -216,7 +216,7 @@ public static unsafe SafeFreeCredentials AcquireCredentialsHandleSchCredentials(
credential.paCred = &certificateHandle;
}
- if (NetEventSource.IsEnabled) NetEventSource.Info($"flags=({flags}), ProtocolFlags=({protocolFlags}), EncryptionPolicy={policy}");
+ if (NetEventSource.Log.IsEnabled()) NetEventSource.Info($"flags=({flags}), ProtocolFlags=({protocolFlags}), EncryptionPolicy={policy}");
if (protocolFlags != 0)
{