mirror of https://github.com/sbt/sbt.git
Merge pull request #6557 from eed3si9n/wip/proxy_terminal
lazily initialize ProxyTerminal to SimpleTerminal
This commit is contained in:
commit
62f6bd15e2
|
|
@ -346,7 +346,7 @@ object Terminal {
|
|||
consoleTerminalHolder.set(newConsoleTerminal())
|
||||
if (hasVirtualIO) {
|
||||
hasProgress.set(isServer && isAnsiSupported)
|
||||
activeTerminal.set(consoleTerminalHolder.get)
|
||||
Terminal.set(consoleTerminalHolder.get)
|
||||
try withOut(withIn(f))
|
||||
finally {
|
||||
jline.TerminalFactory.reset()
|
||||
|
|
@ -382,7 +382,16 @@ object Terminal {
|
|||
}
|
||||
|
||||
private[this] object ProxyTerminal extends Terminal {
|
||||
private def t: Terminal = activeTerminal.get
|
||||
private def t: Terminal = {
|
||||
val current = activeTerminal.get
|
||||
// if the activeTerminal is yet to be initialized on use,
|
||||
// initialize to the conventional simple terminal for compatibility and testing
|
||||
if (current ne null) current
|
||||
else {
|
||||
Terminal.set(Terminal.SimpleTerminal)
|
||||
activeTerminal.get
|
||||
}
|
||||
}
|
||||
override private[sbt] def progressState: ProgressState = t.progressState
|
||||
override private[sbt] def enterRawMode(): Unit = t.enterRawMode()
|
||||
override private[sbt] def exitRawMode(): Unit = t.exitRawMode()
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class ManagedLoggerSpec extends FlatSpec with Matchers {
|
|||
"ManagedLogger" should "log to console" in {
|
||||
val log = newLogger("foo")
|
||||
context.addAppender("foo", asyncStdout -> Level.Info)
|
||||
log.info("test")
|
||||
log.debug("test")
|
||||
log.info("test_info")
|
||||
log.debug("test_debug")
|
||||
}
|
||||
|
||||
it should "support event logging" in {
|
||||
|
|
|
|||
Loading…
Reference in New Issue