add fake debug and trace loggers
This commit is contained in:
parent
c426e625d3
commit
acaca1a04e
|
@ -14,6 +14,7 @@ class MatterLinkConfig(file: File) : BaseConfig() {
|
|||
getBoolean = config::getBoolean,
|
||||
getString = config::getString,
|
||||
getStringValidated = config::getString,
|
||||
getStringValidValues = config::getString,
|
||||
getStringList = config::getStringList,
|
||||
addCustomCategoryComment = config::addCustomCategoryComment
|
||||
)
|
||||
|
|
|
@ -14,6 +14,7 @@ class MatterLinkConfig(file: File) : BaseConfig() {
|
|||
getBoolean = config::getBoolean,
|
||||
getString = config::getString,
|
||||
getStringValidated = config::getString,
|
||||
getStringValidValues = config::getString,
|
||||
getStringList = config::getStringList,
|
||||
addCustomCategoryComment = config::addCustomCategoryComment
|
||||
)
|
||||
|
|
|
@ -14,10 +14,10 @@ class MatterLinkConfig(file: File) : BaseConfig() {
|
|||
getBoolean = config::getBoolean,
|
||||
getString = config::getString,
|
||||
getStringValidated = config::getString,
|
||||
getStringValidValues = config::getString,
|
||||
getStringList = config::getStringList,
|
||||
addCustomCategoryComment = config::addCustomCategoryComment
|
||||
)
|
||||
|
||||
if (config.hasChanged()) config.save()
|
||||
cfg = this
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package matterlink
|
||||
|
||||
import matterlink.bridge.MessageHandler
|
||||
import matterlink.config.cfg
|
||||
|
||||
lateinit var instance: IMatterLink
|
||||
|
||||
|
@ -25,7 +26,14 @@ abstract class IMatterLink {
|
|||
fun error(formatString: String, vararg data: Any) = log("ERROR", formatString, *data)
|
||||
fun warn(formatString: String, vararg data: Any) = log("WARN", formatString, *data)
|
||||
fun info(formatString: String, vararg data: Any) = log("INFO", formatString, *data)
|
||||
fun debug(formatString: String, vararg data: Any) = log("DEBUG", formatString, *data)
|
||||
fun trace(formatString: String, vararg data: Any) = log("TRACE", formatString, *data)
|
||||
fun debug(formatString: String, vararg data: Any) {
|
||||
if (cfg!!.relay.logLevel == "DEBUG" || cfg!!.relay.logLevel == "TRACE")
|
||||
log("INFO", "DEBUG: " + formatString.replace("\n", "\nDEBUG: "), *data)
|
||||
}
|
||||
|
||||
fun trace(formatString: String, vararg data: Any) {
|
||||
if (cfg!!.relay.logLevel == "TRACE")
|
||||
log("INFO", "TRACE: " + formatString.replace("\n", "\nTRACE: "), *data)
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ class HttpStreamConnection(getClosure: () -> HttpGet,
|
|||
if (chars > 0) {
|
||||
buffer += String(buf.dropLast(buf.count() - chars).toByteArray())
|
||||
|
||||
instance.debug(buffer)
|
||||
instance.trace(buffer)
|
||||
|
||||
while (buffer.contains("\n")) {
|
||||
val line = buffer.substringBefore("\n")
|
||||
|
|
|
@ -50,7 +50,7 @@ object MessageHandler {
|
|||
rcvQueue.add(
|
||||
ApiMessage.decode(it)
|
||||
)
|
||||
instance.debug("Received: " + it)
|
||||
// instance.debug("Received: " + it)
|
||||
},
|
||||
{
|
||||
instance.warn("Bridge connection closed!")
|
||||
|
|
|
@ -24,7 +24,8 @@ abstract class BaseConfig {
|
|||
|
||||
data class RelayOptions(
|
||||
var systemUser: String = "Server",
|
||||
var advancements: Boolean = true
|
||||
var advancements: Boolean = true,
|
||||
var logLevel: String = "INFO"
|
||||
)
|
||||
|
||||
data class FormattingOptions(
|
||||
|
@ -94,6 +95,7 @@ abstract class BaseConfig {
|
|||
getBoolean: (key: String, category: String, default: Boolean, comment: String) -> Boolean,
|
||||
getString: (key: String, category: String, default: String, comment: String) -> String,
|
||||
getStringValidated: (key: String, category: String, default: String, comment: String, pattern: Pattern) -> String,
|
||||
getStringValidValues: (key: String, category: String, default: String, comment: String, validValues: Array<String>) -> String,
|
||||
addCustomCategoryComment: (key: String, comment: String) -> Unit,
|
||||
getStringList: (name: String, category: String, defaultValues: Array<String>, comment: String) -> Array<String>
|
||||
) {
|
||||
|
@ -111,6 +113,13 @@ abstract class BaseConfig {
|
|||
category,
|
||||
relay.advancements,
|
||||
"Relay player advancements"
|
||||
),
|
||||
logLevel = getStringValidValues(
|
||||
"logLevel",
|
||||
category,
|
||||
relay.logLevel,
|
||||
"MatterLink log level",
|
||||
arrayOf("INFO", "DEBUG", "TRACE")
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue