Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: align LogWarning with LogError #2987

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,33 @@ internal static void LogInfo<TArg, TArg2, TArg3>(
/// </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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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