Skip to content

Commit

Permalink
fix: set logger supplier in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Apehum committed Apr 20, 2024
1 parent 841624f commit 1df9d7f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/src/test/kotlin/su/plo/voice/addon/TestVoice.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package su.plo.voice.addon

import su.plo.slib.api.logging.McLoggerFactory
import su.plo.voice.BaseVoice
import su.plo.voice.addon.logging.JavaLogger
import su.plo.voice.util.version.ModrinthLoader
import java.io.File

object TestVoice : BaseVoice(ModrinthLoader.FABRIC) {

init {
McLoggerFactory.supplier = McLoggerFactory.Supplier { name -> JavaLogger(name) }
}

override fun getConfigFolder(): File {
TODO("Not yet implemented")
}
Expand Down
30 changes: 30 additions & 0 deletions common/src/test/kotlin/su/plo/voice/addon/logging/JavaLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package su.plo.voice.addon.logging

import su.plo.slib.api.logging.McLogger
import java.util.logging.Level
import java.util.logging.Logger

class JavaLogger(
name: String
) : Logger(name, null), McLogger {

override fun trace(format: String, vararg arguments: Any?) {
log(Level.FINEST, String.format(format, *arguments))
}

override fun debug(format: String, vararg arguments: Any?) {
log(Level.ALL, String.format(format, *arguments))
}

override fun info(format: String, vararg arguments: Any?) {
log(Level.INFO, String.format(format, *arguments))
}

override fun warn(format: String, vararg arguments: Any?) {
log(Level.WARNING, String.format(format, *arguments))
}

override fun error(format: String, vararg arguments: Any?) {
log(Level.SEVERE, String.format(format, *arguments))
}
}

0 comments on commit 1df9d7f

Please sign in to comment.