mirror of https://github.com/sbt/sbt.git
use current project's logLevel for command logging
This commit is contained in:
parent
36d2394208
commit
be1bdbb350
|
|
@ -294,15 +294,21 @@ object BuiltinCommands
|
|||
s
|
||||
}
|
||||
def lastGrep = Command(LastGrepCommand, lastGrepBrief, lastGrepDetailed)(lastGrepParser) { case (s,(pattern,sk)) =>
|
||||
Output.lastGrep(sk, Project.structure(s).streams, pattern)
|
||||
val (str, ref) = extractLast(s)
|
||||
Output.lastGrep(sk, str, pattern, ref)
|
||||
s
|
||||
}
|
||||
def extractLast(s: State) = {
|
||||
val ext = Project.extract(s)
|
||||
(ext.structure.streams, Select(ext.currentRef))
|
||||
}
|
||||
def inspectParser = (s: State) => token((Space ~> ("actual" ^^^ true)) ?? false) ~ spacedKeyParser(s)
|
||||
val spacedKeyParser = (s: State) => Act.requireSession(s, token(Space) ~> Act.scopedKeyParser(s))
|
||||
val optSpacedKeyParser = (s: State) => spacedKeyParser(s).?
|
||||
def lastGrepParser(s: State) = Act.requireSession(s, (token(Space) ~> token(NotSpace, "<pattern>")) ~ optSpacedKeyParser(s))
|
||||
def last = Command(LastCommand, lastBrief, lastDetailed)(optSpacedKeyParser) { (s,sk) =>
|
||||
Output.last(sk, Project.structure(s).streams)
|
||||
val (str, ref) = extractLast(s)
|
||||
Output.last(sk, str, ref)
|
||||
s
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,16 +23,16 @@ object Output
|
|||
None
|
||||
}
|
||||
|
||||
def last(key: Option[ScopedKey[_]], mgr: Streams): Unit =
|
||||
printLines(lastLines(key, mgr))
|
||||
def last(key: Option[ScopedKey[_]], mgr: Streams, ref: ScopeAxis[ProjectRef]): Unit =
|
||||
printLines(lastLines(key, mgr, ref))
|
||||
def printLines(lines: Seq[String]) = lines foreach println
|
||||
def lastGrep(key: Option[ScopedKey[_]], mgr: Streams, patternString: String)
|
||||
def lastGrep(key: Option[ScopedKey[_]], mgr: Streams, patternString: String, ref: ScopeAxis[ProjectRef])
|
||||
{
|
||||
val pattern = Pattern.compile(patternString)
|
||||
printLines(lastLines(key, mgr).flatMap(showMatches(pattern)) )
|
||||
printLines(lastLines(key, mgr, ref).flatMap(showMatches(pattern)) )
|
||||
}
|
||||
def lastLines(key: Option[ScopedKey[_]], mgr: Streams): Seq[String] =
|
||||
lastLines(key getOrElse Project.globalLoggerKey, mgr)
|
||||
def lastLines(key: Option[ScopedKey[_]], mgr: Streams, ref: ScopeAxis[ProjectRef]): Seq[String] =
|
||||
lastLines(key getOrElse Project.globalLoggerKey(ref), mgr)
|
||||
def lastLines(key: ScopedKey[_], mgr: Streams): Seq[String] =
|
||||
mgr.use(key) { s => IO.readLines(s.readText( Project.fillTaskAxis(key) )) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ object Project extends Init[Scope] with ProjectExtra
|
|||
def updateCurrent(s0: State): State =
|
||||
{
|
||||
val structure = Project.structure(s0)
|
||||
val s = installGlobalLogger(s0, structure)
|
||||
val ref = Project.current(s)
|
||||
val ref = Project.current(s0)
|
||||
val s = installGlobalLogger(s0, structure, ref)
|
||||
val project = Load.getProject(structure.units, ref.build, ref.project)
|
||||
logger(s).info("Set current project to " + ref.project + " (in build " + ref.build +")")
|
||||
def get[T](k: SettingKey[T]): Option[T] = k in ref get structure.data
|
||||
|
|
@ -290,10 +290,10 @@ object Project extends Init[Scope] with ProjectExtra
|
|||
val extracted = Project.extract(state)
|
||||
EvaluateTask.evaluateTask(extracted.structure, taskKey, state, extracted.currentRef, checkCycles, maxWorkers)
|
||||
}
|
||||
def globalLoggerKey = fillTaskAxis(ScopedKey(GlobalScope, streams.key))
|
||||
def installGlobalLogger(s: State, structure: BuildStructure): State =
|
||||
def globalLoggerKey(ref: ScopeAxis[ResolvedReference]) = fillTaskAxis(ScopedKey(GlobalScope.copy(project = ref), streams.key))
|
||||
def installGlobalLogger(s: State, structure: BuildStructure, ref: ProjectRef): State =
|
||||
{
|
||||
val str = structure.streams(globalLoggerKey)
|
||||
val str = structure.streams(globalLoggerKey(Select(ref)))
|
||||
str.open()
|
||||
s.put(logged, str.log).addExitHook { str.close() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue