-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Log to Console
and Debug
when targeting MAUI
#3373
Conversation
I did a quick check with our |
I'm fine with the behaviour change in general because I assume that this is nothing that affects users in production |
Nice catch... tricky though. As we initialise Blazor using plain old We could create a WASM integration with a Alternatively, we could just document/show in the WASM sample that the DiagnosticLogger needs to be set to something non-default (explaining that |
I tried using this all day and I think I changed my mind. I found this to be fairly irritating to have the SDK logs show up somewhere else than the rest of the program's logs. TLDR; this felt like a major breaking change. |
We could revisit the initial solution but implement it more simply, like this: public class TraceAndConsoleDiagnosticLogger : DiagnosticLogger
{
public TraceAndConsoleDiagnosticLogger(SentryLevel minimalLevel) : base(minimalLevel)
{
}
protected override void LogMessage(string message)
{
Trace.WriteLine(message);
Console.WriteLine(message);
}
} It would create duplication if you had a console tracer configured, but I'd say that's a bit of an edge case (and we could guide people to change the default logger in those cases). |
I think we agreed on the sync to try to log to both via the MAUI setup to catch those VS users? |
Console
and Debug
when targeting MAUI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks!
Resolves #3341
Approach
There are a couple of different ways we could solve this. One would be a CompositeLogger which could be initialised like this:
That would basically log to both. It's a bit of a hack since technically, you could instantiate each of the composite loggers with a different
DiagnosticLevel
. That could be guarded against by checking all the levels match in the constructor but it's not as elegant as I'd like.Alternatively, we could default to a DebugDiagnosticLogger which uses
Debug.WriteLine
. That works in both Rider and Visual Studio.It's a small change to the behavriour of the API. Anyone who wanted to retain the previous behaviour could explicitly set
SentryOptions.DiagnosticLogger
to be aConsoleDiagnosticLogger
.In this PR, I've gone with that option.