KotlinLogging - option to globally disable logging

This commit is contained in:
2026-09-12 20:29:20 +01:00
parent 7384642a6d
commit ab88896b01
4 changed files with 21 additions and 7 deletions
@@ -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()