diff --git a/main/Aggregation.scala b/main/Aggregation.scala index a680a9ee8..21268684b 100644 --- a/main/Aggregation.scala +++ b/main/Aggregation.scala @@ -3,7 +3,6 @@ */ package sbt - import CommandSupport.logger import Project.ScopedKey import Load.BuildStructure import Keys.{aggregate, showSuccess, showTiming, timingFormat} @@ -83,7 +82,7 @@ final object Aggregation val start = System.currentTimeMillis val (newS, result) = withStreams(structure){ str => runTask(toRun, s,str, structure.index.triggers, maxWorkers = workers)(nodeView(s, str, extra.tasks, extra.values)) } val stop = System.currentTimeMillis - val log = logger(newS) + val log = newS.log val success = result match { case Value(_) => true; case Inc(_) => false } try { onResult(result, log) { results => if(show) printSettings(results, log) } } @@ -148,7 +147,7 @@ final object Aggregation case xs @ KeyValue(_, _: InputStatic[t]) :: _ => applyTasks(s, structure, maps(xs.asInstanceOf[Values[InputStatic[t]]])(_.parser(s)), show) case xs @ KeyValue(_, _: InputDynamic[t]) :: _ => applyDynamicTasks(s, structure, xs.asInstanceOf[Values[InputDynamic[t]]], show) case xs @ KeyValue(_, _: Task[t]) :: _ => applyTasks(s, structure, maps(xs.asInstanceOf[Values[Task[t]]])(x => success(x)), show) - case xs => success(() => { printSettings(xs, logger(s)); s} ) + case xs => success(() => { printSettings(xs, s.log); s} ) } private[this] def maps[T, S](vs: Values[T])(f: T => S): Values[S] = vs map { case KeyValue(k,v) => KeyValue(k, f(v)) } diff --git a/main/Command.scala b/main/Command.scala index b652b7c82..929a757a7 100644 --- a/main/Command.scala +++ b/main/Command.scala @@ -5,7 +5,6 @@ package sbt import java.io.File import complete.{DefaultParsers, EditDistance, Parser} - import CommandSupport.logger sealed trait Command { def help: Seq[Help] @@ -92,7 +91,7 @@ object Command case Left(failures) => val (msgs,pos) = failures() val errMsg = commandError(command, msgs, pos) - logger(state).error(errMsg) + state.log.error(errMsg) state.fail } } diff --git a/main/GlobalPlugin.scala b/main/GlobalPlugin.scala index a241f4c61..a317c73ef 100644 --- a/main/GlobalPlugin.scala +++ b/main/GlobalPlugin.scala @@ -42,7 +42,7 @@ object GlobalPlugin val p: Scope = Scope.GlobalScope in ProjectRef(root, rootProject(root)) val taskInit = (projectID, projectDependencies, projectDescriptors, resolvers, fullClasspath in Runtime, internalDependencyClasspath in Runtime, exportedProducts in Runtime, ivyModule) map { (pid, pdeps, pdescs, rs, cp, intcp, prods, mod) => - val depMap = pdescs + mod.dependencyMapping(log(state)) + val depMap = pdescs + mod.dependencyMapping(state.log) GlobalPluginData(pid, pdeps, depMap, rs, cp, prods ++ intcp) } val task = taskInit mapReferenced Project.mapScope(Scope replaceThis p) evaluate data @@ -54,10 +54,9 @@ object GlobalPlugin withStreams(structure) { str => val nv = nodeView(state, str) val (newS, result) = runTask(t, state, str, structure.index.triggers)(nv) - (newS, processResult(result, log(newS))) + (newS, processResult(result, newS.log)) } } - private[this] def log(s: State) = CommandSupport.logger(s) val globalPluginSettings = inScope(Scope.GlobalScope in LocalRootProject)(Seq( organization := "org.scala-tools.sbt", onLoadMessage <<= Keys.baseDirectory("Loading global plugins from " + _), diff --git a/main/IvyConsole.scala b/main/IvyConsole.scala index 09467a457..d974c82fe 100644 --- a/main/IvyConsole.scala +++ b/main/IvyConsole.scala @@ -13,11 +13,11 @@ object IvyConsole final val Name = "ivy-console" lazy val command = Command.command(Name) { state => - val Dependencies(managed, repos, unmanaged) = parseDependencies(state.remainingCommands, CommandSupport.logger(state)) + val Dependencies(managed, repos, unmanaged) = parseDependencies(state.remainingCommands, state.log) val base = new File(CommandSupport.bootDirectory(state), Name) IO.createDirectory(base) - val (eval, structure) = Load.defaultLoad(state, base, CommandSupport.logger(state)) + val (eval, structure) = Load.defaultLoad(state, base, state.log) val session = Load.initialSession(structure, eval) val extracted = Project.extract(session, structure) import extracted._ diff --git a/main/Main.scala b/main/Main.scala index 52b5c0e0f..0f59601e0 100644 --- a/main/Main.scala +++ b/main/Main.scala @@ -310,7 +310,7 @@ object BuiltinCommands def history = Command.custom(historyParser, historyHelp) def historyParser(s: State): Parser[() => State] = Command.applyEffect(HistoryCommands.actionParser) { histFun => - val logError = (msg: String) => CommandSupport.logger(s).error(msg) + val logError = (msg: String) => s.log.error(msg) val hp = s get historyPath.key getOrElse None val lines = hp.toList.flatMap( p => IO.readLines(p) ).toIndexedSeq histFun( complete.History(lines, hp, logError) ) match diff --git a/main/Project.scala b/main/Project.scala index b439591d5..146fd7ce7 100644 --- a/main/Project.scala +++ b/main/Project.scala @@ -9,7 +9,6 @@ package sbt import Keys.{appConfiguration, stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, sessionVars, shellPrompt, thisProject, thisProjectRef, watch} import Scope.{GlobalScope,ThisScope} import Load.BuildStructure - import CommandSupport.logger import Types.{idFun, Id} sealed trait ProjectDefinition[PR <: ProjectReference] @@ -79,7 +78,7 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings, val rkey = Project.mapScope(Scope.resolveScope(GlobalScope, currentRef.build, rootProject) )( key.scopedKey ) val value: Option[(State, Result[T])] = apply(structure, key.task.scopedKey, state, currentRef) val (newS, result) = getOrError(rkey.scope, rkey.key, value) - (newS, processResult(result, logger(newS))) + (newS, processResult(result, newS.log)) } private def getOrError[T](scope: Scope, key: AttributeKey[_], value: Option[T])(implicit display: Show[ScopedKey[_]]): T = value getOrElse error(display(ScopedKey(scope, key)) + " is undefined.") @@ -179,7 +178,7 @@ object Project extends Init[Scope] with ProjectExtra val ref = Project.current(s) val project = Load.getProject(structure.units, ref.build, ref.project) val msg = Keys.onLoadMessage in ref get structure.data getOrElse "" - if(!msg.isEmpty) logger(s).info(msg) + if(!msg.isEmpty) s.log.info(msg) def get[T](k: SettingKey[T]): Option[T] = k in ref get structure.data def commandsIn(axis: ResolvedReference) = commands in axis get structure.data toList ; diff --git a/main/ProjectNavigation.scala b/main/ProjectNavigation.scala index 09013b60c..b3846de05 100644 --- a/main/ProjectNavigation.scala +++ b/main/ProjectNavigation.scala @@ -6,7 +6,6 @@ package sbt import ProjectNavigation._ import Project.updateCurrent import Keys.sessionSettings - import CommandSupport.logger import complete.{DefaultParsers, Parser} import DefaultParsers._ import java.net.URI @@ -39,7 +38,7 @@ final class ProjectNavigation(s: State) if(to.length > 1) gotoParent(to.length - 1, nav, s) else s */ // semantics currently undefined } - def show(): Unit = logger(s).info(currentRef.project + " (in build " + currentRef.build + ")") + def show(): Unit = s.log.info(currentRef.project + " (in build " + currentRef.build + ")") def selectProject(uri: URI, to: String): State = if( structure.units(uri).defined.contains(to) ) setProject(uri, to) @@ -54,7 +53,7 @@ final class ProjectNavigation(s: State) def fail(msg: String): State = { - logger(s).error(msg) + s.log.error(msg) s.fail } diff --git a/main/Script.scala b/main/Script.scala index 623db937f..2be888410 100644 --- a/main/Script.scala +++ b/main/Script.scala @@ -19,7 +19,7 @@ object Script val base = new File(CommandSupport.bootDirectory(state), hash) IO.createDirectory(base) - val (eval, structure) = Load.defaultLoad(state, base, CommandSupport.logger(state)) + val (eval, structure) = Load.defaultLoad(state, base, state.log) val session = Load.initialSession(structure, eval) val extracted = Project.extract(session, structure) import extracted._ diff --git a/main/SessionSettings.scala b/main/SessionSettings.scala index 94a87bb7f..14038d841 100644 --- a/main/SessionSettings.scala +++ b/main/SessionSettings.scala @@ -7,7 +7,6 @@ package sbt import java.net.URI import Project._ import Types.Endo - import CommandSupport.logger import compiler.Eval import SessionSettings._ @@ -47,7 +46,7 @@ object SessionSettings import extracted._ if(session.append.isEmpty) { - logger(s).info("No session settings defined.") + s.log.info("No session settings defined.") s } else @@ -59,7 +58,7 @@ object SessionSettings { val oldSettings = (oldState get Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) if(newSession.append.isEmpty && !oldSettings.isEmpty) - logger(oldState).warn("Discarding " + pluralize(oldSettings.size, " session setting") + ". Use 'session save' to persist session settings.") + oldState.log.warn("Discarding " + pluralize(oldSettings.size, " session setting") + ". Use 'session save' to persist session settings.") } def removeRanges[T](in: Seq[T], ranges: Seq[(Int,Int)]): Seq[T] = { diff --git a/main/State.scala b/main/State.scala index 2dd2cc37e..b9cb6082d 100644 --- a/main/State.scala +++ b/main/State.scala @@ -5,7 +5,7 @@ package sbt import java.io.File import java.util.concurrent.Callable - import CommandSupport.FailureWall + import CommandSupport.{FailureWall, logger} final case class State( configuration: xsbti.AppConfiguration, @@ -43,6 +43,7 @@ trait StateOps { def update[T](key: AttributeKey[T])(f: Option[T] => T): State def has(key: AttributeKey[_]): Boolean def baseDir: File + def log: Logger def locked[T](file: File)(t: => T): T def runExitHooks(): State def addExitHook(f: => Unit): State @@ -77,6 +78,7 @@ object State def update[T](key: AttributeKey[T])(f: Option[T] => T): State = put(key, f(get(key))) def has(key: AttributeKey[_]) = s.attributes contains key def remove(key: AttributeKey[_]) = s.copy(attributes = s.attributes remove key) + def log = CommandSupport.logger(s) def fail = { val remaining = s.remainingCommands.dropWhile(_ != FailureWall) diff --git a/main/Structure.scala b/main/Structure.scala index 3c6414dff..23e207c28 100644 --- a/main/Structure.scala +++ b/main/Structure.scala @@ -143,7 +143,7 @@ object Scoped } final class RichInitialize[S](init: Initialize[S]) { - @deprecated("A call to 'identity' is no longer necessary and can be removed.") + @deprecated("A call to 'identity' is no longer necessary and can be removed.", "0.11.0") final def identity: Initialize[S] = init def map[T](f: S => T): Initialize[Task[T]] = init(s => mktask(f(s)) ) def flatMap[T](f: S => Task[T]): Initialize[Task[T]] = init(f) @@ -162,7 +162,7 @@ object Scoped def task: SettingKey[Task[S]] = scopedSetting(scope, key) def get(settings: Settings[Scope]): Option[Task[S]] = settings.get(scope, key) - @deprecated("A call to 'identity' is no longer necessary and can be removed.") + @deprecated("A call to 'identity' is no longer necessary and can be removed.", "0.11.0") def identity: Initialize[Task[S]] = this def ? : Initialize[Task[Option[S]]] = Project.optional(scopedKey) { case None => mktask { None }; case Some(t) => t map some.fn } diff --git a/main/Watched.scala b/main/Watched.scala index da595d912..539dc10c0 100644 --- a/main/Watched.scala +++ b/main/Watched.scala @@ -61,7 +61,7 @@ object Watched (triggered, newWatchState, s) } catch { case e: Exception => - val log = CommandSupport.logger(s) + val log = s.log log.error("Error occurred obtaining files to watch. Terminating continuous execution...") BuiltinCommands.handleException(e, s, log) (false, watchState, s.fail)