Last active
April 12, 2018 08:34
-
-
Save kakajika/a50df49ee1cf1a2e4b05e63419d24dcf to your computer and use it in GitHub Desktop.
Timber Tree implementation for logging with DeployGate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeployGateTree : Timber.Tree() { | |
override fun log(priority: Int, taf: String?, message: String, t: Throwable?) { | |
when (priority) { | |
Log.VERBOSE -> DeployGate.logVerbose(message) | |
Log.INFO -> DeployGate.logInfo(message) | |
Log.DEBUG -> DeployGate.logDebug(message) | |
Log.WARN -> DeployGate.logWarn(message) | |
Log.ERROR -> DeployGate.logError(message) | |
} | |
} | |
} | |
// in Application.kt | |
DeployGate.registerCallback(object : DeployGateCallback { | |
override fun onInitialized(isServiceAvailable: Boolean) { | |
} | |
override fun onStatusChanged(isManaged: Boolean, isAuthorized: Boolean, loginUsername: String?, isStopped: Boolean) { | |
if (isManaged) { | |
Timber.plant(DeployGateTree()) | |
} | |
} | |
override fun onUpdateAvailable(p0: Int, p1: String?, p2: Int) { | |
} | |
}, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment