log-timber
A Timber tree that forwards logs to the nRF Logger app.
An nRFLoggerTree forwards log messages to the nRF Logger app (or to a local content provider), so you can keep using Timber's familiar API while your logs end up in an nRF Logger session. This module builds on the log module.
Setup
The library is available on Maven Central and transitively includes the log module:
implementation("no.nordicsemi.android:log-timber:2.5.0")Usage
Plant an nRFLoggerTree as described on the Timber website. Once planted, all Timber calls are written to the underlying log session:
Timber.plant(new nRFLoggerTree(context, deviceAddress, deviceName));
Timber.i("Connected");
Timber.e(exception, "Connection failed");The tree can be created from a device key/name, from an existing ILogSession, or from a session Uri. Use nRFLoggerTree.newSession to start a new session on an already-planted tree, and nRFLoggerTree.setLoggingTagsEnabled to control whether tags are prefixed to messages. If neither nRF Logger nor a local provider is available, the logs are ignored.
Things to keep in mind
Timber's priorities do not map one-to-one onto nRF Logger's log levels:
This module uses
@NonNulland@Nullablefrom androidx.annotation rather than the org.jetbrains.annotations ones that Timber uses.Timber has no
APPLICATIONlevel, and itsDEBUGhas a higher priority thanVERBOSE. As a result, entries logged through Timber's own methods (e.g.Timber.i(...)) can never be logged at theAPPLICATIONlevel.Log.VERBOSEpriority is mapped to theVERBOSElevel (upgraded), andLog.DEBUGpriority is mapped to theDEBUGlevel (downgraded).By default the tag is prepended to the message as
[TAG] message. Calltree.setLoggingTagsEnabled(false)to disable this (since 2.5).