修复设置 redirectNetworkLogToDirectory 后日志 identity 为 Bot 的问题 fix #1743 (#1751)

This commit is contained in:
StarWishsama 2021-12-22 06:57:46 +08:00 committed by GitHub
parent 10af69f05e
commit 53883e885c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -408,7 +408,7 @@ public open class BotConfiguration { // open for Java
@ConfigurationDsl
public fun redirectBotLogToFile(
file: File = File("mirai.log"),
identity: (bot: Bot) -> String = { "Net ${it.id}" }
identity: (bot: Bot) -> String = { "Bot ${it.id}" }
) {
require(!file.isDirectory) { "file must not be a dir" }
botLoggerSupplier = { SingleFileLogger(identity(it), workingDir.resolve(file)) }
@ -425,7 +425,7 @@ public open class BotConfiguration { // open for Java
public fun redirectBotLogToDirectory(
dir: File = File("logs"),
retain: Long = 1.weeksToMillis,
identity: (bot: Bot) -> String = { "Net ${it.id}" }
identity: (bot: Bot) -> String = { "Bot ${it.id}" }
) {
require(!dir.isFile) { "dir must not be a file" }
botLoggerSupplier = { DirectoryLogger(identity(it), workingDir.resolve(dir), retain) }
@ -644,4 +644,4 @@ internal val deviceInfoStub: (Bot) -> DeviceInfo = {
private val logger by lazy {
MiraiLogger.Factory.create(BotConfiguration::class)
}
}