-
-
Notifications
You must be signed in to change notification settings - Fork 226
Open
Labels
.NETPull requests that update .net codePull requests that update .net codeFeatureNew feature or requestNew feature or requestLogging
Milestone
Description
This is the current code:
sentry-dotnet/src/Sentry/SentryOptions.cs
Lines 620 to 668 in 6274944
| /// <summary> | |
| /// Whether to log diagnostics messages | |
| /// </summary> | |
| /// <remarks> | |
| /// The verbosity can be controlled through <see cref="DiagnosticLevel"/> | |
| /// and the implementation via <see cref="DiagnosticLogger"/>. | |
| /// </remarks> | |
| public bool Debug | |
| { | |
| get => _debug; | |
| set => _debug = value; | |
| } | |
| /// <summary> | |
| /// The diagnostics level to be used | |
| /// </summary> | |
| /// <remarks> | |
| /// The <see cref="Debug"/> flag has to be switched on for this setting to take effect. | |
| /// </remarks> | |
| public SentryLevel DiagnosticLevel { get; set; } = SentryLevel.Debug; | |
| private volatile IDiagnosticLogger? _diagnosticLogger; | |
| /// <summary> | |
| /// The implementation of the logger. | |
| /// </summary> | |
| /// <remarks> | |
| /// The <see cref="Debug"/> flag has to be switched on for this logger to be used at all. | |
| /// When debugging is turned off, this property is made null and any internal logging results in a no-op. | |
| /// </remarks> | |
| public IDiagnosticLogger? DiagnosticLogger | |
| { | |
| get => Debug ? _diagnosticLogger : null; | |
| set | |
| { | |
| if (value is null) | |
| { | |
| _diagnosticLogger?.LogDebug( | |
| "Sentry will not emit SDK debug messages because debug mode has been turned off."); | |
| } | |
| else | |
| { | |
| _diagnosticLogger?.LogInfo("Replacing current logger with: '{0}'.", value.GetType().Name); | |
| } | |
| _diagnosticLogger = value; | |
| } | |
| } |
What this effectively does, AFAICT, is that we don't print any warnings when Debug is not set. That is pretty unexpected behavior, at least to me, especially considering what the docs say when you're setting up sentry:
// When debug is enabled, the Sentry client will emit detailed debugging information to the console.
// This might be helpful, or might interfere with the normal operation of your application.
// We enable it here for demonstration purposes when first trying Sentry.
// You shouldn't do this in your applications unless you're troubleshooting issues with Sentry.
options.Debug = true;
Instead, I'd expect the DiagnosticLogger property to always be reachable. It already has a check which log levels should be printed.
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .net codePull requests that update .net codeFeatureNew feature or requestNew feature or requestLogging
Projects
Status
Done