Skip to content

Instantly share code, notes, and snippets.

@gseitz
Created July 22, 2011 21:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gseitz/1100428 to your computer and use it in GitHub Desktop.
Save gseitz/1100428 to your computer and use it in GitHub Desktop.
RetroLogger - Bringing old school log level commands to sbt-0.10.x
//
// 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