Tracer's own logging
info
This information is about Tracer SDK's own logging. It is not in any way related to what SDK sends to the server. Own logging is only for Tracer SDK and/or its integration in your project.
HasTracerLogger
and TracerLoggerDelegate
description
Tracer does its own logging via the TracerLoggerDelegate
interface. To swizzle the logging mechanism, implement HasTracerLogger
in you app.
If you just want to change the logging level, you can create an instance of DefaultTracerLoggerDelegate
(see below).
class MyApplication : Application, HasTracerLogger {
override val tracerLoggerDelegate: TracerLoggerDelegate
get() = DefaultTracerLoggerDelegate(
minLogPriority = Log.VERBOSE, |\| --- |```j|
)
}
You can completely override the logging mechanism in your TracerLoggerDelegate
implementation (see below).
class MyApplication : Application, HasTracerLogger {
override val tracerLoggerDelegate: TracerLoggerDelegate
get() = MyLoggerDelegate()
}
class MyLoggerDelegate : TracerLoggerDelegate {
// Event logging lowest level. Constants from from android.util.Log are used
// By default, the lowest logging level is Log.DEBUG
override val minLogPriority: Int
get() = Log.VERBOSE
// Main logging method
//
// priority - logging level. Constants from from android.util.Log are used
// msg - optional message.
// tr - optional exception.
override fun println(priority: Int, msg: String?, tr: Throwable?) {
// your logging code
TODO()
// optionally redirect to the built-in implementation
// will be sent to android logcat with the ru.ok.tracer tag
DefaultTracerLoggerDelegate.println(priority, msg, tr)
}
}