Question about the general mental model #746
|
I really like scribe, but I find it difficult to wrap my head around how the API is supposed to work sometimes. For example, given the following: val logger: Logger = scribe.Logger.root.clearHandlers().withHandler(minimumLevel = Some(Level.Debug))
logger.warn("Warn")
logger.info("Info")
logger.debug("Debug")I would assume the val logger: Logger = scribe.Logger.root.clearHandlers().clearModifiers().withHandler(minimumLevel = Some(Level.Debug))I've searched through the Wiki, but I haven't found an explanation that helps me internalize why this is. Any tips or pointers? |
Replies: 2 comments 1 reply
|
It's understandable. If you were doing this with anything but Logger.root, this wouldn't be an issue, but the root logger gets configured by default like: root
.orphan()
.clearModifiers()
.withMinimumLevel(DefaultRootMinimumLevel)
.clearHandlers()
.withHandler()
.replace(Some("root"))The Sorry for the late reply, I haven't been paying much attention to GH. |
|
The reason is that the minimumLevel on a handler is optional, so if it's not set it will log everything. This is why the modifier exists so any handlers added inherit the minimum level filtering. |
It's understandable. If you were doing this with anything but Logger.root, this wouldn't be an issue, but the root logger gets configured by default like:
root .orphan() .clearModifiers() .withMinimumLevel(DefaultRootMinimumLevel) .clearHandlers() .withHandler() .replace(Some("root"))The
withMinimumLevelsets a modifier that has to be cleared.Sorry for the late reply, I haven't been paying much attention to GH.