优化
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import io.legado.app.help.globalExecutor
|
||||
import java.util.logging.Handler
|
||||
import java.util.logging.LogRecord
|
||||
|
||||
class AsyncHandler(private val delegate: Handler) : Handler() {
|
||||
|
||||
override fun publish(record: LogRecord?) {
|
||||
globalExecutor.execute {
|
||||
delegate.publish(record)
|
||||
}
|
||||
}
|
||||
|
||||
override fun flush() {
|
||||
delegate.flush()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
delegate.close()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun Handler.asynchronous() = AsyncHandler(this)
|
||||
@@ -69,7 +69,7 @@ object LogUtils {
|
||||
} else {
|
||||
Level.OFF
|
||||
}
|
||||
}
|
||||
}.asynchronous()
|
||||
}
|
||||
|
||||
private val consoleHandler by lazy {
|
||||
@@ -85,7 +85,7 @@ object LogUtils {
|
||||
} else {
|
||||
Level.OFF
|
||||
}
|
||||
}
|
||||
}.asynchronous()
|
||||
}
|
||||
|
||||
fun upLevel() {
|
||||
|
||||
Reference in New Issue
Block a user