mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
improve logging performance
This commit is contained in:
parent
4e6013ed92
commit
8f2edfcc75
@ -67,7 +67,7 @@ interface ChatComponent {
|
||||
companion object {
|
||||
|
||||
@JvmOverloads
|
||||
fun of(raw: Any?, translator: Translator? = null, parent: TextComponent? = null): ChatComponent {
|
||||
fun of(raw: Any?, translator: Translator? = null, parent: TextComponent? = null, ignoreJson: Boolean = false): ChatComponent {
|
||||
if (raw == null) {
|
||||
return BaseComponent()
|
||||
}
|
||||
@ -88,9 +88,11 @@ interface ChatComponent {
|
||||
is JsonPrimitive -> raw.asString
|
||||
else -> raw.toString()
|
||||
}
|
||||
try {
|
||||
return BaseComponent(translator, parent, JsonParser.parseString(string).asJsonObject)
|
||||
} catch (ignored: RuntimeException) {
|
||||
if (!ignoreJson) {
|
||||
try {
|
||||
return BaseComponent(translator, parent, JsonParser.parseString(string).asJsonObject)
|
||||
} catch (ignored: RuntimeException) {
|
||||
}
|
||||
}
|
||||
|
||||
return BaseComponent(parent, string)
|
||||
|
@ -100,16 +100,16 @@ object Log {
|
||||
is Throwable -> {
|
||||
val stringWriter = StringWriter()
|
||||
message.printStackTrace(PrintWriter(stringWriter))
|
||||
ChatComponent.of(stringWriter.toString())
|
||||
ChatComponent.of(stringWriter.toString(), ignoreJson = true)
|
||||
}
|
||||
is String -> {
|
||||
if (formatting.isNotEmpty()) {
|
||||
ChatComponent.of(message.format(*formatting))
|
||||
ChatComponent.of(message.format(*formatting), ignoreJson = true)
|
||||
} else {
|
||||
ChatComponent.of(message)
|
||||
ChatComponent.of(message, ignoreJson = true)
|
||||
}
|
||||
}
|
||||
else -> ChatComponent.of(message)
|
||||
else -> ChatComponent.of(message, ignoreJson = true)
|
||||
}
|
||||
|
||||
LOG_QUEUE.add(
|
||||
|
Loading…
x
Reference in New Issue
Block a user