mirror of
https://github.com/gedoor/legado.git
synced 2024-07-04 23:36:56 +08:00
优化
This commit is contained in:
parent
c3b7b02f8c
commit
cf42f8c3e8
25
app/src/main/java/io/legado/app/utils/AsyncHandler.kt
Normal file
25
app/src/main/java/io/legado/app/utils/AsyncHandler.kt
Normal file
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user