Remove use of deprecated MiraiLogger.TopLevel

This commit is contained in:
Him188 2021-11-06 14:44:58 +00:00
parent bb9c9d7aa4
commit e3dcaf6654
4 changed files with 22 additions and 6 deletions

View File

@ -52,7 +52,7 @@ internal class Handler<in E : Event> internal constructor(
subscriberContext[CoroutineExceptionHandler]?.handleException(subscriberContext, e)
?: currentCoroutineContext()[CoroutineExceptionHandler]?.handleException(subscriberContext, e)
?: kotlin.run {
val logger = if (event is BotEvent) event.bot.logger else MiraiLogger.TopLevel
val logger = if (event is BotEvent) event.bot.logger else logger
val subscriberName = subscriberContext[CoroutineName]?.name ?: "<unnamed>"
val broadcasterName = currentCoroutineContext()[CoroutineName]?.name ?: "<unnamed>"
val message =
@ -68,6 +68,12 @@ internal class Handler<in E : Event> internal constructor(
ListeningStatus.LISTENING
}
}
companion object {
private val logger by lazy {
MiraiLogger.Factory.create(Handler::class)
}
}
}
internal class ListenerRegistry(

View File

@ -20,11 +20,15 @@ internal val SeleniumLoginSolver: LoginSolver? by lazy {
} catch (ignore: ClassNotFoundException) {
null
} catch (error: Throwable) {
MiraiLogger.TopLevel.warning("Error in loading mirai-login-solver-selenium, skip", error)
logger.warning("Error in loading mirai-login-solver-selenium, skip", error)
null
}
}
private val logger by lazy {
MiraiLogger.Factory.create(LoginSolver::class)
}
// null -> 该情况为 user 确认能自己传入 ticket, 不需要 Selenium 的帮助
// true -> SeleniumLoginSolver 支持
// false-> 无法提供默认滑块验证解决器

View File

@ -637,7 +637,11 @@ public inline fun BotConfiguration(block: BotConfiguration.() -> Unit): BotConfi
}
internal val deviceInfoStub: (Bot) -> DeviceInfo = {
MiraiLogger.TopLevel.warning("未指定设备信息, 已使用随机设备信息. 请查看 BotConfiguration.deviceInfo 以获取更多信息.")
MiraiLogger.TopLevel.warning("Device info isn't specified. Please refer to BotConfiguration.deviceInfo for more information")
logger.warning("未指定设备信息, 已使用随机设备信息. 请查看 BotConfiguration.deviceInfo 以获取更多信息.")
logger.warning("Device info isn't specified. Please refer to BotConfiguration.deviceInfo for more information")
DeviceInfo.random()
}
private val logger by lazy {
MiraiLogger.Factory.create(BotConfiguration::class)
}

View File

@ -144,12 +144,12 @@ internal object WindowHelperJvm {
Toolkit.getDefaultToolkit()
if (Desktop.isDesktopSupported()) {
MiraiLogger.TopLevel.info(
logger.info(
"""
Mirai 正在使用桌面环境. 如遇到验证码将会弹出对话框. 可添加 JVM 属性 `mirai.no-desktop` 以关闭.
""".trimIndent()
)
MiraiLogger.TopLevel.info(
logger.info(
"""
Mirai is using desktop. Captcha will be thrown by window popup. You can add `mirai.no-desktop` to JVM properties (-Dmirai.no-desktop) to disable it.
""".trimIndent()
@ -162,6 +162,8 @@ internal object WindowHelperJvm {
return@run PlatformKind.CLI
}
}
private val logger by lazy { MiraiLogger.Factory.create(this::class) }
}