You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
840 B
Kotlin
27 lines
840 B
Kotlin
4 years ago
|
package me.eater.hefbrug.logging.message
|
||
|
|
||
|
import me.eater.hefbrug.utils.handlebars
|
||
|
import org.apache.logging.log4j.message.Message
|
||
|
import org.apache.logging.log4j.util.StringBuilderFormattable
|
||
|
|
||
|
open class HefbrugMessage(private val message: String, private val items: Map<String, Any?>) : Message,
|
||
|
StringBuilderFormattable {
|
||
|
constructor(message: String, vararg items: Pair<String, Any?>) : this(message, items.toMap())
|
||
|
|
||
|
override fun getThrowable(): Throwable? = null
|
||
|
override fun getParameters(): Array<Any> {
|
||
|
return items.entries.toTypedArray()
|
||
|
}
|
||
|
|
||
|
override fun getFormattedMessage(): String {
|
||
|
return format.handlebars(items)
|
||
|
}
|
||
|
|
||
|
override fun getFormat(): String {
|
||
|
return message
|
||
|
}
|
||
|
|
||
|
override fun formatTo(buffer: StringBuilder) {
|
||
|
buffer.append(formattedMessage)
|
||
|
}
|
||
|
}
|