mirror of https://github.com/sbt/sbt.git
Transfer logging,trace levels from old to new global loggers.
This commit is contained in:
parent
57306e6257
commit
fb1437cf36
|
|
@ -65,9 +65,22 @@ object MainLoop
|
|||
def runWithNewLog(state: State, logBacking: GlobalLogBacking): RunNext =
|
||||
Using.fileWriter(append = true)(logBacking.file) { writer =>
|
||||
val out = new java.io.PrintWriter(writer)
|
||||
val loggedState = state.copy(globalLogging = state.globalLogging.newLogger(out, logBacking))
|
||||
val newLogging = state.globalLogging.newLogger(out, logBacking)
|
||||
transferLevels(state, newLogging)
|
||||
val loggedState = state.copy(globalLogging = newLogging)
|
||||
try run(loggedState) finally out.close()
|
||||
}
|
||||
|
||||
/** Transfers logging and trace levels from the old global loggers to the new ones. */
|
||||
private[this] def transferLevels(state: State, logging: GlobalLogging) {
|
||||
val old = state.globalLogging
|
||||
Logger.transferLevels(old.backed, logging.backed)
|
||||
(old.full, logging.full) match { // well, this is a hack
|
||||
case (oldLog: AbstractLogger, newLog: AbstractLogger) => Logger.transferLevels(oldLog, newLog)
|
||||
case _ => ()
|
||||
}
|
||||
}
|
||||
|
||||
sealed trait RunNext
|
||||
final class ClearGlobalLog(val state: State) extends RunNext
|
||||
final class KeepGlobalLog(val state: State) extends RunNext
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ abstract class AbstractLogger extends Logger
|
|||
|
||||
object Logger
|
||||
{
|
||||
def transferLevels(oldLog: AbstractLogger, newLog: AbstractLogger) {
|
||||
newLog.setLevel(oldLog.getLevel)
|
||||
newLog.setTrace(oldLog.getTrace)
|
||||
}
|
||||
|
||||
// make public in 0.13
|
||||
private[sbt] val Null: AbstractLogger = new AbstractLogger {
|
||||
def getLevel: Level.Value = Level.Error
|
||||
|
|
|
|||
Loading…
Reference in New Issue