Replies: 5 comments
-
Is there a reason for not using ILogger? This gives a lot of flexibility to the end user. |
Beta Was this translation helpful? Give feedback.
-
Absolutely none. Seems like a good idea to implement it :) |
Beta Was this translation helpful? Give feedback.
-
Agree with Bart here, if there are existing constructs within .NET we can leverage for this we definitely should. |
Beta Was this translation helpful? Give feedback.
-
my 10 cents here: I think that we can use an instance for this, it will provide a way to extend this class and maybe integrate it with appcenter... I mean, maybe some logs are interesting to track in the appcenter or another "issues tracker", like a local database. protected override OnLog(string message, StatusLevel level)
{
if (level == StatusLevel.Critical)
TrackOnMyCustomIssueTracker(message);
base.OnLog(string message, StatusLevel level);
} Another thing is catch unhandled exceptions, we can catch it with app domain: AppDomain.CurrentDomain.UnhandledException += OnUnhandledExceptionDetected;
private static void OnUnhandledExceptionDetected(object sender, UnhandledExceptionEventArgs args) {
var e = (Exception)args?.ExceptionObject;
//do logging strategy
} And, for Android, we have the public class AndroidUncaughtExceptionTracker : IUncaughtExceptionHandler
{
private readonly IUncaughtExceptionHandler _innerHandler;
protected AndroidUncaughtExceptionTracker(IUncaughtExceptionHandler inner)
{
_innerHandler = inner;
}
public void OnUnhandledExceptionDetected(object sender, UnhandledExceptionEventArgs args) {
var e = (System.Exception)args?.ExceptionObject;
//do logging strategy
_innerHandler?.OnUnhandledExceptionDetected(sender, args);
}
public static void Register()
{
if (Java.Lang.Thread.DefaultUncaughtExceptionHandler is AndroidUncaughtExceptionTracker)
return;
var exceptionTracker = new AndroidUncaughtExceptionTracker(Java.Lang.Thread.DefaultUncaughtExceptionHandler);
Java.Lang.Thread.DefaultUncaughtExceptionHandler = exceptionTracker;
}
} |
Beta Was this translation helpful? Give feedback.
-
@roubachof @jfversluis Any agreement on how this will be implemented since then? any update about this issue? |
Beta Was this translation helpful? Give feedback.
-
Summary
What should we do when the state of one component is incorrect due to violated prerequisites, incorrect behavior (aka bug)?
To defeat the "fail silently" vs "crash in prod" dilemma, we could have a configurable internal logger that will log any warning or error detected in the components.
API Changes
Something close to this maybe:
https://github.com/roubachof/Sharpnado.Shadows/blob/master/Shadows/Shadows/InternalLogger.cs
The logger can be enabled or disabled by the user.
The user could also provide its own delegate to handle the error messages.
It could be useful when attaching logs to crash reports (nice feature from app center).
Intended Use Case
Beta Was this translation helpful? Give feedback.
All reactions