ConsoleLogger
Console logger that writes logs to the platform console and allows transforming the runtime tag.
This logger is useful on platforms that produce a lot of internal logs (e.g. certain Android devices). The tagTransformer function lets callers format, shorten, sanitize, prefix, or completely replace the runtime tag before it is passed to the underlying platform print routine.
Parameters
minimum log level this logger outputs. Default: Level.VERBOSE.
Lumberjack filter used to decide which logs are allowed. Default: DefaultLumberjackFilter.
function called for every log with the runtime tag (may be null) and returning the final tag to use (or null to indicate no tag). The default is the identity function ({ it }) which leaves the runtime tag unchanged.
Notes and recommendations:
tagTransformeris invoked on every log call and therefore should be fast and side-effect free.If you want to include a fixed prefix/tag, you can capture it from the surrounding scope:
val logger = ConsoleLogger(tagTransformer = { tag -> if (tag != null) "FIXED-$tag" else "FIXED" })The transformer may return
nullif no tag should be used.
Note: The logger intentionally places className before the "(file:line)" part so IDEs/logcat can make the filename:line clickable.