Add logback extensions, coloured output, toggleable logging in IRCClient
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package com.shr4pnel.ferretirc.net
|
||||
|
||||
import com.shr4pnel.ferretirc.net.messages.ServerMessage
|
||||
import com.shr4pnel.ferretirc.util.Helpers
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.slf4j.logger
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import org.slf4j.helpers.NOPLogger
|
||||
|
||||
class MessageParser(val incoming: Channel<String>) {
|
||||
class MessageParser(val incoming: Channel<String>, enableLogging: Boolean = false) {
|
||||
val incomingParsedMessages = Channel<ServerMessage>()
|
||||
private val logger = if (Helpers.enableLogging) KotlinLogging.logger {} else KotlinLogging.logger(NOPLogger.NOP_LOGGER)
|
||||
private val logger = if (enableLogging) KotlinLogging.logger {} else KotlinLogging.logger(NOPLogger.NOP_LOGGER)
|
||||
|
||||
class MessageBuilder {
|
||||
private var tags: String? = null
|
||||
@@ -154,7 +153,7 @@ class MessageParser(val incoming: Channel<String>) {
|
||||
suspend fun start() {
|
||||
val builder = MessageBuilder()
|
||||
for (msg in incoming) {
|
||||
logger.trace { "Receiving: $msg" }
|
||||
logger.debug { "Receiving: $msg" }
|
||||
incomingParsedMessages.send(builder.build(msg))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user