Skip to content

Commit 12971e3

Browse files
committed
chore: align LogWarning with LogError (#2987)
1 parent 91467a0 commit 12971e3

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
- The User.IpAddress is now set to {{auto}} by default, even when sendDefaultPII is disabled ([#2981](https://github.com/getsentry/sentry-dotnet/pull/2981))
1414
- The "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io can be used to control this instead
15+
- The `DiagnosticLogger` signature for `LogWarning` changed to take the `exception` as the first parameter. That way it does no longer get mixed up with the TArgs. ([#2987](https://github.com/getsentry/sentry-dotnet/pull/2987))
1516

1617
### Dependencies
1718

src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,33 @@ internal static void LogInfo<TArg, TArg2, TArg3>(
166166
/// </summary>
167167
public static void LogWarning(
168168
this IDiagnosticLogger logger,
169-
string message,
170-
Exception? exception = null)
169+
string message)
170+
=> logger.LogIfEnabled(SentryLevel.Warning, null, message);
171+
172+
/// <summary>
173+
/// Log a warning message.
174+
/// </summary>
175+
internal static void LogWarning(
176+
this SentryOptions options,
177+
string message)
178+
=> options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, null, message);
179+
180+
/// <summary>
181+
/// Log a warning message.
182+
/// </summary>
183+
public static void LogWarning(
184+
this IDiagnosticLogger logger,
185+
Exception exception,
186+
string message)
171187
=> logger.LogIfEnabled(SentryLevel.Warning, exception, message);
172188

173189
/// <summary>
174190
/// Log a warning message.
175191
/// </summary>
176192
internal static void LogWarning(
177193
this SentryOptions options,
178-
string message,
179-
Exception? exception = null)
194+
Exception exception,
195+
string message)
180196
=> options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, exception, message);
181197

182198
/// <summary>

test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
11741174
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11751175
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11761176
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
1177-
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
1177+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
1178+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
11781179
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11791180
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11801181
}

test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
11741174
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11751175
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11761176
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
1177-
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
1177+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
1178+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
11781179
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11791180
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11801181
}

test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,8 @@ namespace Sentry.Extensibility
11751175
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11761176
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11771177
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
1178-
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
1178+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
1179+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
11791180
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11801181
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11811182
}

test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,8 @@ namespace Sentry.Extensibility
11711171
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11721172
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11731173
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
1174-
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
1174+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
1175+
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
11751176
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
11761177
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
11771178
}

0 commit comments

Comments
 (0)