šŸ› Keep reference to logger around so its configuration isnā€™t lost
authorDavid ā€˜Bombeā€™ Roden <bombe@pterodactylus.net>
Tue, 1 Oct 2024 16:12:16 +0000 (18:12 +0200)
committerDavid ā€˜Bombeā€™ Roden <bombe@pterodactylus.net>
Tue, 1 Oct 2024 16:12:16 +0000 (18:12 +0200)
src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt

index 98a177b..f108371 100644 (file)
@@ -236,19 +236,19 @@ class DefaultElementLoaderTest {
 
        private val loggedRecords = mutableListOf<LogRecord>()
 
-       init {
-               Logger.getLogger(DefaultElementLoader::class.qualifiedName)
-                       .apply { level = ALL }
-                       .apply {
-                               addHandler(object : Handler() {
-                                       override fun publish(record: LogRecord) {
-                                               loggedRecords += record
-                                       }
-
-                                       override fun flush() = Unit
-                                       override fun close() = Unit
-                               })
+       @Suppress("unused")
+       // keep this instance around so its configuration isnā€™t lost
+       private val logger = Logger.getLogger(DefaultElementLoader::class.qualifiedName)
+       .apply { level = ALL }
+       .apply {
+               addHandler(object : Handler() {
+                       override fun publish(record: LogRecord) {
+                               loggedRecords += record
                        }
+
+                       override fun flush() = Unit
+                       override fun close() = Unit
+               })
        }
 
 }