mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
perf(extension): 优化 printExtensionFileConflictError 日志输出.
Kotlin-logging 在日志输出方法中做了检查, 如果级别未开启则不会调用方法获取日志内容, 故将内容构造部分移入 error 代码块以避免无意义的生成日志内容.
This commit is contained in:
parent
cf8e746bd4
commit
1afe0f07a8
@ -145,22 +145,24 @@ internal class ExtensionLoader(
|
||||
extensionArtifact: Artifact,
|
||||
foundResult: Map<ExtensionPackageFinder, Set<FoundExtensionPackage>>
|
||||
) {
|
||||
val errMessage = StringBuilder(
|
||||
"""
|
||||
[Bot ${bot.botUsername}] 扩展包 $extensionArtifact 存在多个文件, 为防止安全问题, 已禁止加载该扩展包:
|
||||
""".trimIndent()
|
||||
).append('\n')
|
||||
log.error {
|
||||
val errMessage = StringBuilder(
|
||||
"""
|
||||
[Bot ${bot.botUsername}] 扩展包 $extensionArtifact 存在多个文件, 为防止安全问题, 已禁止加载该扩展包:
|
||||
""".trimIndent()
|
||||
).append('\n')
|
||||
|
||||
foundResult.forEach { (finder, files) ->
|
||||
errMessage.append("\t- 搜索器 `").append(finder::class.simpleName).append("`")
|
||||
.append("(Priority: ${finder.getPriority()})")
|
||||
.append(" 找到了以下扩展包: \n")
|
||||
for (file in files) {
|
||||
errMessage.append("\t\t* ")
|
||||
.append(URLDecoder.decode(file.getRawUrl().toString(), StandardCharsets.UTF_8)).append('\n')
|
||||
foundResult.forEach { (finder, files) ->
|
||||
errMessage.append("\t- 搜索器 `").append(finder::class.simpleName).append("`")
|
||||
.append("(Priority: ${finder.getPriority()})")
|
||||
.append(" 找到了以下扩展包: \n")
|
||||
for (file in files) {
|
||||
errMessage.append("\t\t* ")
|
||||
.append(URLDecoder.decode(file.getRawUrl().toString(), StandardCharsets.UTF_8)).append('\n')
|
||||
}
|
||||
}
|
||||
errMessage
|
||||
}
|
||||
log.error { errMessage }
|
||||
}
|
||||
|
||||
private fun getExtensionDataFolder(extensionArtifact: Artifact): File {
|
||||
|
Loading…
Reference in New Issue
Block a user