Last active
January 26, 2017 11:21
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
package com.github.rschatz | |
import com.twitter.app.App | |
// other imports | |
trait LoggingSetup { self: App => | |
private val root = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME).asInstanceOf[Logger] | |
private val context = root.getLoggerContext | |
private[this] val logLevel = flag( | |
"log.level", | |
"info", | |
"Default log level (root logger). One of {trace, debug, info, warn, error}" | |
) | |
init { | |
context.reset() | |
context.setName("whatever") | |
context.addTurboFilter(BroadcastContextOverrideFilter) // explained below | |
} | |
premain { | |
val level = // convert logLevel() to a ch.qos.logback.classic.Level | |
root.setLevel(level) | |
// setup appenders etc. | |
} | |
onExit { | |
// stop context | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment