Logging is something that every application needs, but it shouldn't be a burden to change analytic/crash providers. Write your app once with overlogger and then switch out providers on the fly.
Being an Xamarin developer and going from Xamarin Insights, to HockeyApp, and then to App Center I got tired having to rewrite my logging logic each time I was forced to change. This library lets me write it once and then log to one or more than one provider at a time!
- NETStandard 2.0
- iOS (10+)
- Android (4.4+)
Simple. First, pick which provider you want to use. We currently support
- App Center
- Bugsnag
- Console
- More to come (create an issue!)
If you don't want to wait for me to create one, just implement IReporter
on your own class.
var appCenterReporter = new AppCenterReporter("MY-KEY");
Logger.AddCrashReporter(appCenterReporter);
That's it. If you want to add another, just do the it twice!
var appCenterReporter = new AppCenterReporter("MY-KEY");
var bugSnagReporter = new BugSnagReporter("MY-KEY");
Logger.AddCrashReporter(appCenterReporter);
Logger.AddCrashReporter(bugSnagReporter);
Once a reporter is added, start logging away! Or if you start logging before a reporter is added, we'll keep track of that and then send the logs once a reporter is added.
Logger.Log(LogLevel.Info, "My Message");
Logger.Log(LogLevel.Info, "My Message", "MY-TAG");
Logger.Log(LogLevel.Error, "My Error", new Exception("My Exception"));
Logger.Log(LogLevel.Error, "My Error", new Exception("My Exception"), "MY-TAG");
You can even track events if the reporter supports it (most do)
Logger.TrackEvent("My Custom Event");
Logger.TrackEvent("My Custom Event", new Dictionary<string, string>() { "My Property", "My Value" });
If you don't want logs below a certain level to be reported, we'll take care of that for you too! Just pass the log level to either all reporters or just a specific one.
Logger.SetLogLevel(LogLevel.Warn); // For all reporters
Logger.SetLogLevelForReporter<AppCenterReporter>(LogLevel.Error); // Just the App Center Reporter
If you want to remove a reporter, just pass the Type
Logger.RemoveCrashReporter<AppCenterReporter>();