KotlinLogging - option to globally disable logging
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
package com.shr4pnel.ferretirc.net
|
||||
|
||||
import com.shr4pnel.ferretirc.irc.util.Helpers
|
||||
import com.shr4pnel.ferretirc.net.messages.MessageIO
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.slf4j.logger
|
||||
import io.ktor.network.sockets.Socket
|
||||
import io.ktor.network.sockets.openWriteChannel
|
||||
import io.ktor.utils.io.ByteWriteChannel
|
||||
import io.ktor.utils.io.writeFully
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.slf4j.helpers.NOPLogger
|
||||
|
||||
class MessageWriter(socket: Socket, scope: CoroutineScope) : MessageIO(socket, scope) {
|
||||
private lateinit var send: ByteWriteChannel
|
||||
private val logger = KotlinLogging.logger("MessageWriter")
|
||||
private val logger = if (Helpers.enableLogging) KotlinLogging.logger {} else KotlinLogging.logger(NOPLogger.NOP_LOGGER)
|
||||
|
||||
override fun start() = scope.launch {
|
||||
send = socket.openWriteChannel()
|
||||
|
||||
Reference in New Issue
Block a user