mirror of https://github.com/sbt/sbt.git
Merge pull request #4232 from eed3si9n/wip/run-logging
Fixes the stacktrace of run
This commit is contained in:
commit
a46c07d5f6
|
|
@ -302,7 +302,7 @@ lazy val runProj = (project in file("run"))
|
||||||
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy$default$*"),
|
exclude[DirectMissingMethodProblem]("sbt.OutputStrategy#LoggedOutput.copy$default$*"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.configure(addSbtIO, addSbtUtilLogging, addSbtCompilerClasspath)
|
.configure(addSbtIO, addSbtUtilLogging, addSbtUtilControl, addSbtCompilerClasspath)
|
||||||
|
|
||||||
val sbtProjDepsCompileScopeFilter =
|
val sbtProjDepsCompileScopeFilter =
|
||||||
ScopeFilter(inDependencies(LocalProject("sbtProj"), includeRoot = false), inConfigurations(Compile))
|
ScopeFilter(inDependencies(LocalProject("sbtProj"), includeRoot = false), inConfigurations(Compile))
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,8 @@ object Defaults extends BuildCommon {
|
||||||
classpathEntryDefinesClass :== FileValueCache(Locate.definesClass _).get,
|
classpathEntryDefinesClass :== FileValueCache(Locate.definesClass _).get,
|
||||||
traceLevel in run :== 0,
|
traceLevel in run :== 0,
|
||||||
traceLevel in runMain :== 0,
|
traceLevel in runMain :== 0,
|
||||||
|
traceLevel in bgRun :== 0,
|
||||||
|
traceLevel in fgRun :== 0,
|
||||||
traceLevel in console :== Int.MaxValue,
|
traceLevel in console :== Int.MaxValue,
|
||||||
traceLevel in consoleProject :== Int.MaxValue,
|
traceLevel in consoleProject :== Int.MaxValue,
|
||||||
autoCompilerPlugins :== true,
|
autoCompilerPlugins :== true,
|
||||||
|
|
|
||||||
|
|
@ -198,13 +198,19 @@ object LogManager {
|
||||||
val scope = task.scope
|
val scope = task.scope
|
||||||
val screenLevel = getOr(logLevel.key, data, scope, state, Level.Info)
|
val screenLevel = getOr(logLevel.key, data, scope, state, Level.Info)
|
||||||
val backingLevel = getOr(persistLogLevel.key, data, scope, state, Level.Debug)
|
val backingLevel = getOr(persistLogLevel.key, data, scope, state, Level.Debug)
|
||||||
|
val screenTrace = getOr(traceLevel.key, data, scope, state, 0)
|
||||||
val execOpt = state.currentCommand
|
val execOpt = state.currentCommand
|
||||||
val loggerName: String = s"bg-${task.key.label}-${generateId.incrementAndGet}"
|
val loggerName: String = s"bg-${task.key.label}-${generateId.incrementAndGet}"
|
||||||
val channelName: Option[String] = execOpt flatMap (_.source map (_.channelName))
|
val channelName: Option[String] = execOpt flatMap (_.source map (_.channelName))
|
||||||
// val execId: Option[String] = execOpt flatMap { _.execId }
|
// val execId: Option[String] = execOpt flatMap { _.execId }
|
||||||
val log = LogExchange.logger(loggerName, channelName, None)
|
val log = LogExchange.logger(loggerName, channelName, None)
|
||||||
LogExchange.unbindLoggerAppenders(loggerName)
|
LogExchange.unbindLoggerAppenders(loggerName)
|
||||||
val consoleOpt = consoleLocally(state, console)
|
val consoleOpt = consoleLocally(state, console) map {
|
||||||
|
case a: ConsoleAppender =>
|
||||||
|
a.setTrace(screenTrace)
|
||||||
|
a
|
||||||
|
case a => a
|
||||||
|
}
|
||||||
LogExchange.bindLoggerAppenders(
|
LogExchange.bindLoggerAppenders(
|
||||||
loggerName,
|
loggerName,
|
||||||
(consoleOpt.toList map { _ -> screenLevel }) ::: (relay -> backingLevel) :: Nil
|
(consoleOpt.toList map { _ -> screenLevel }) ::: (relay -> backingLevel) :: Nil
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import java.lang.reflect.{ Method, Modifier }
|
||||||
import Modifier.{ isPublic, isStatic }
|
import Modifier.{ isPublic, isStatic }
|
||||||
import sbt.internal.inc.classpath.ClasspathUtilities
|
import sbt.internal.inc.classpath.ClasspathUtilities
|
||||||
import sbt.internal.inc.ScalaInstance
|
import sbt.internal.inc.ScalaInstance
|
||||||
|
import sbt.internal.util.MessageOnlyException
|
||||||
|
|
||||||
import sbt.io.Path
|
import sbt.io.Path
|
||||||
|
|
||||||
|
|
@ -29,7 +30,9 @@ class ForkRun(config: ForkOptions) extends ScalaRun {
|
||||||
if (exitCode == 0) Success(())
|
if (exitCode == 0) Success(())
|
||||||
else
|
else
|
||||||
Failure(
|
Failure(
|
||||||
new RuntimeException(s"""Nonzero exit code returned from $label: $exitCode""".stripMargin)
|
new MessageOnlyException(
|
||||||
|
s"""Nonzero exit code returned from $label: $exitCode""".stripMargin
|
||||||
|
)
|
||||||
)
|
)
|
||||||
val process = fork(mainClass, classpath, options, log)
|
val process = fork(mainClass, classpath, options, log)
|
||||||
def cancel() = {
|
def cancel() = {
|
||||||
|
|
@ -124,6 +127,6 @@ object Run {
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
log.debug("Exited with code 0")
|
log.debug("Exited with code 0")
|
||||||
Success(())
|
Success(())
|
||||||
} else Failure(new RuntimeException("Nonzero exit code: " + exitCode))
|
} else Failure(new MessageOnlyException("Nonzero exit code: " + exitCode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue