Translations: 简体中文
Sketch logs are provided by the Logger component. By default, android.util.Log is used for
output, and the Tag is unified to Sketch
Like android.util.Log, Logger also supports Level, the default is INFO
You can modify it when initializing Sketch, as follows:
class MyApplication : Application(), SketchFactory {
override fun createSketch(): Sketch {
return Sketch.Builder(this).apply {
logger(Logger(Logger.Level.DEBUG))
}.build()
}
}
You can also provide options in the App settings to modify them at any time, as follows:
context.sketch.logger.level = Logger.Level.DEBUG
Note: Excessive Log logs will affect UI fluency. Please set the level to INFO and above for the official release version.
Logger outputs to android.util.Log by default. You can implement the Logger.Proxy interface to customize new output, and then modify it when initializing Sketch, as follows:
class MyProxy : Logger.Proxy {
override fun v(tag: String, msg: String, tr: Throwable?) {
Log.v(tag, msg, tr)
}
override fun d(tag: String, msg: String, tr: Throwable?) {
Log.d(tag, msg, tr)
}
override fun i(tag: String, msg: String, tr: Throwable?) {
Log.i(tag, msg, tr)
}
override fun w(tag: String, msg: String, tr: Throwable?) {
Log.w(tag, msg, tr)
}
override fun e(tag: String, msg: String, tr: Throwable?) {
Log.e(tag, msg, tr)
}
override fun flush() {
}
override fun toString(): String = "MyProxy"
}
class MyApplication : Application(), SketchFactory {
override fun createSketch(): Sketch {
return Sketch.Builder(this).apply {
logger(Logger(Logger.Level.DEBUG, MyProxy()))
}.build()
}
}