Created
July 22, 2011 21:09
-
-
Save gseitz/1100428 to your computer and use it in GitHub Desktop.
RetroLogger - Bringing old school log level commands to sbt-0.10.x
This file contains hidden or 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
// | |
// RetroLogger | |
// A handy sbt-0.10.x plugin that allows you to set the log level like in the old days (aka sbt-0.7.x) | |
// "set logLevel := Level.Debug" ====> "debug" | |
// | |
// + put this file in ~/.sbt/plugins/ | |
// + add "sbtPlugin := true" to ~/.sbt/plugins/build.sbt | |
import sbt._ | |
import Keys._ | |
object RetroLogger extends Plugin { | |
private def log(level: String) = (state: State) => | |
BuiltinCommands.addAlias(state, level, "set logLevel := Level.%s%s" format (level.head.toUpper, level.tail)) | |
// The workaround from above. | |
override lazy val settings: Seq[Setting[_]] = Seq[Setting[_]]( | |
onLoad in Global <<= (onLoad in Global) ?? identity[State], | |
onLoad in Global ~= { oldState => | |
log("error") compose log("warn") compose log("info") compose log("debug") compose oldState | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment