Skip to content

Commit

Permalink
chore: align LogWarning with LogError (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Dec 22, 2023
1 parent 91467a0 commit 12971e3
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@

- The User.IpAddress is now set to {{auto}} by default, even when sendDefaultPII is disabled ([#2981](https://github.com/getsentry/sentry-dotnet/pull/2981))
- The "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io can be used to control this instead
- 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))

### Dependencies

Expand Down
24 changes: 20 additions & 4 deletions src/Sentry/Extensibility/DiagnosticLoggerExtensions.cs
Expand Up @@ -166,17 +166,33 @@ public static class DiagnosticLoggerExtensions
/// </summary>
public static void LogWarning(
this IDiagnosticLogger logger,
string message,
Exception? exception = null)
string message)
=> logger.LogIfEnabled(SentryLevel.Warning, null, message);

/// <summary>
/// Log a warning message.
/// </summary>
internal static void LogWarning(
this SentryOptions options,
string message)
=> options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, null, message);

/// <summary>
/// Log a warning message.
/// </summary>
public static void LogWarning(
this IDiagnosticLogger logger,
Exception exception,
string message)
=> logger.LogIfEnabled(SentryLevel.Warning, exception, message);

/// <summary>
/// Log a warning message.
/// </summary>
internal static void LogWarning(
this SentryOptions options,
string message,
Exception? exception = null)
Exception exception,
string message)
=> options.DiagnosticLogger?.LogIfEnabled(SentryLevel.Warning, exception, message);

/// <summary>
Expand Down
Expand Up @@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
Expand Down
Expand Up @@ -1174,7 +1174,8 @@ namespace Sentry.Extensibility
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
Expand Down
Expand Up @@ -1175,7 +1175,8 @@ namespace Sentry.Extensibility
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
Expand Down
3 changes: 2 additions & 1 deletion test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Expand Up @@ -1171,7 +1171,8 @@ namespace Sentry.Extensibility
public static void LogInfo<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogInfo<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
public static void LogInfo<TArg, TArg2, TArg3>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2, TArg3 arg3) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message, System.Exception? exception = null) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, string message) { }
public static void LogWarning(this Sentry.Extensibility.IDiagnosticLogger logger, System.Exception exception, string message) { }
public static void LogWarning<TArg>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg) { }
public static void LogWarning<TArg, TArg2>(this Sentry.Extensibility.IDiagnosticLogger logger, string message, TArg arg, TArg2 arg2) { }
}
Expand Down

0 comments on commit 12971e3

Please sign in to comment.