Add logback extensions, coloured output, toggleable logging in IRCClient

This commit is contained in:
2026-09-15 03:03:15 +01:00
parent becc871f52
commit 8611ebb1ea
14 changed files with 201 additions and 46 deletions
@@ -4,7 +4,7 @@ import com.shr4pnel.ferretirc.net.messages.ServerMessage
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
@@ -20,7 +20,7 @@ class IrcClientTest {
companion object {
lateinit var processes: MutableList<Process>
val client = IrcClient("localhost", 6667)
val client = IrcClient("localhost", 6667, enableLogging = true)
private val logger = KotlinLogging.logger {}
@JvmStatic
@@ -42,7 +42,10 @@ class IrcClientTest {
),
)
client.connect()
client.register("shr4p", "Tyler D", "password")
client.register("shr4p", "Tyler Fullname", "password")
guestUser.connect()
guestUser.register("guest", "guest", "pass")
client.server
}
@JvmStatic
@@ -103,10 +106,7 @@ class IrcClientTest {
@Test
fun messageLands() =
runBlocking {
val guestUser = IrcClient("localhost", 6667, false)
guestUser.connect()
guestUser.register("guest", "guest", "pass")
runTest {
val channels = client.server.fetchChannels()
val message = Message.PrivMsg(channels.first(), "bring me to life")
guestUser.queueMessage(message)
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<!-- From https://logback.qos.ch/manual/configuration.html -->
<configuration>
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
<import class="ch.qos.logback.core.ConsoleAppender"/>
<include resource="logback-base.xml"/>
<logger name="com.shr4pnel" level="trace" additivity="false">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
</logger>
<root level="warn">
<appender-ref ref="STDOUT"/>
</root>
</configuration>