This commit is contained in:
Horis 2024-03-07 10:24:36 +08:00
parent c3b7b02f8c
commit cf42f8c3e8
2 changed files with 27 additions and 2 deletions

View 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)

View File

@ -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() {