-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I noticed that only `error` was enabled for my Kyo app, when I had it set to info. Info logs should have shown up, but they didn't. ### Solution Check the level of log level enabled in reverse order. In the previous case, `error` was always enabled (unless `off`). ### Notes - I changed `Level` to a `sealed abstract class`, enabling exhaustive pattern matching. Avoiding `AnyVal` is generally better if we know we will only have static instances. - I also added a `CanEqual` for users. ### Checklist - [X] Unit test all changes - [X] Update scaladocs if needed - [X] Update the README if needed Co-authored-by: Flavio Brasil <[email protected]>
- Loading branch information
Showing
3 changed files
with
53 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
kyo-core/jvm/src/test/scala/kyo/internal/LogPlatformSpecificTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kyo.internal | ||
|
||
import kyo.Log.Level | ||
import kyo.Test | ||
import org.slf4j.LoggerFactory | ||
|
||
class LogPlatformSpecificTest extends Test: | ||
private def loggerWithLevel(level: ch.qos.logback.classic.Level) = | ||
val logger = LoggerFactory.getLogger("test") | ||
logger.asInstanceOf[ch.qos.logback.classic.Logger].setLevel(level) | ||
new LogPlatformSpecific.Unsafe.SLF4J(logger) | ||
end loggerWithLevel | ||
|
||
"SLF4J logger" - { | ||
"trace" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.TRACE).level == Level.trace) | ||
} | ||
|
||
"debug" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.DEBUG).level == Level.debug) | ||
} | ||
|
||
"info" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.INFO).level == Level.info) | ||
} | ||
|
||
"warn" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.WARN).level == Level.warn) | ||
} | ||
|
||
"error" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.ERROR).level == Level.error) | ||
} | ||
|
||
"silent" in { | ||
assert(loggerWithLevel(ch.qos.logback.classic.Level.OFF).level == Level.silent) | ||
} | ||
} | ||
end LogPlatformSpecificTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters