This library provides a logger mechanism inspired from both Timber and SLF4J.
Two steps are needed :
- Configure Logger with as much appenders you as want, in the onCreate of your application class
- Call
Logger
's static methods everywhere throughout your app - (optional) You can also use a different formatter to fit your needs on message formatting
Logger.add(DebugAppender("MyProjectTag"))
Logger.add(FirebaseCrashReportingAppender())
Logger.add(HuaweiCrashReportingAppender())
Logger.add(FileAppender("myproject-{date}.log"))
// Optional
Logger.formatter(DefaultFormatter())
Logger.trace("This is trace test number %d", 1)
Logger.debug("This is debug test number %d", 1)
Logger.info("This is info test number %d", 1)
Logger.warn("This is warning test number %d", 1)
Logger.error("This is error test number %d", exception, 1)
Add jcenter's repository in your project's repositories list, then add the dependency.
repositories {
jcenter()
// ...
maven(url = "http://repository.beapp.fr/libs-release-local")
}
dependencies {
implementation("fr.beapp.logger:logger:<latest-release>")
}