Track whether global logging levels were set explicitly by the user or not.

This commit is contained in:
Mark Harrah 2013-10-24 16:34:16 -04:00
parent fb1437cf36
commit 5498275ebd
3 changed files with 10 additions and 1 deletions

View File

@ -10,4 +10,5 @@ object BasicKeys
private[sbt] val interactive = AttributeKey[Boolean]("interactive", "True if commands are currently being entered from an interactive environment.", 10)
private[sbt] val classLoaderCache = AttributeKey[classpath.ClassLoaderCache]("class-loader-cache", "Caches class loaders based on the classpath entries and last modified times.", 10)
private[sbt] val OnFailureStack = AttributeKey[List[Option[String]]]("on-failure-stack", "Stack that remembers on-failure handlers.", 10)
private[sbt] val explicitGlobalLogLevels = AttributeKey[Boolean]("explicit-global-log-levels", "True if the global logging levels were explicitly set by the user.", 10)
}

View File

@ -222,7 +222,7 @@ object State
def locked[T](file: File)(t: => T): T =
s.configuration.provider.scalaProvider.launcher.globalLock.apply(file, new Callable[T] { def call = t })
def interactive = s.get(BasicKeys.interactive).getOrElse(false)
def interactive = getBoolean(s, BasicKeys.interactive, false)
def setInteractive(i: Boolean) = s.put(BasicKeys.interactive, i)
def classLoaderCache: classpath.ClassLoaderCache = s get BasicKeys.classLoaderCache getOrElse newClassLoaderCache
@ -247,4 +247,6 @@ object State
log.error(ErrorHandling reducedToString e)
log.error("Use 'last' for the full log.")
}
private[sbt] def getBoolean(s: State, key: AttributeKey[Boolean], default: Boolean): Boolean =
s.get(key) getOrElse default
}

View File

@ -10,6 +10,7 @@ package sbt
import Def.ScopedKey
import Scope.GlobalScope
import MainLogging._
import BasicKeys.explicitGlobalLogLevels
import Keys.{logLevel, logManager, persistLogLevel, persistTraceLevel, state, traceLevel}
import scala.Console.{BLUE,RESET}
@ -64,6 +65,11 @@ object LogManager
case Select(task) => ScopedKey(key.scope.copy(task = Global), task)
case _ => key // should never get here
}
private[this] def setExplicitGlobalLogLevels(s: State, flag: Boolean): State =
s.put(BasicKeys.explicitGlobalLogLevels, flag)
private[this] def hasExplicitGlobalLogLevels(s: State): Boolean =
State.getBoolean(s, BasicKeys.explicitGlobalLogLevels, default=false)
}
trait LogManager