command logging through Streams, 'last' without a key to redisplay it

This commit is contained in:
Mark Harrah 2011-03-21 20:26:04 -04:00
parent 95e5206c3f
commit c9f8d70ee5
2 changed files with 15 additions and 7 deletions

View File

@ -4,13 +4,15 @@
package sbt
/** Defines a function to call as sbt exits.*/
trait ExitHook extends NotNull
trait ExitHook
{
/** Provides a name for this hook to be used to provide feedback to the user. */
def name: String
/** Subclasses should implement this method, which is called when this hook is executed. */
def runBeforeExiting(): Unit
}
object ExitHook
{
def apply(f: => Unit): ExitHook = new ExitHook { def runBeforeExiting() = f }
}
object ExitHooks
{

View File

@ -1,9 +1,9 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009, 2010 Mark Harrah
* Copyright 2008, 2009, 2010, 2011 Mark Harrah
*/
package sbt
import java.io.{PrintStream, PrintWriter}
import java.io.{BufferedWriter, PrintStream, PrintWriter}
object ConsoleLogger
{
@ -17,8 +17,14 @@ object ConsoleLogger
def printWriterOut(out: PrintWriter): ConsoleOut = new ConsoleOut {
val lockObject = out
def print(s: String) = out.print(s)
def println(s: String) = out.println(s)
def println() = out.println()
def println(s: String) = { out.println(s); out.flush() }
def println() = { out.println(); out.flush() }
}
def bufferedWriterOut(out: BufferedWriter): ConsoleOut = new ConsoleOut {
val lockObject = out
def print(s: String) = out.write(s)
def println(s: String) = { out.write(s); println() }
def println() = { out.newLine(); out.flush() }
}
val formatEnabled =