blob: b886768a4b4af3812bd195c7ce45f738520ecb15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import sbt._
import collection.mutable.ListBuffer
/**
* Logger to capture compiler output, test output
*/
object RecordingLogger extends Logger {
private val buffer = ListBuffer[String]()
def hasErrors = buffer.nonEmpty
def readAndClear() = {
val res = buffer.mkString("\n")
buffer.clear()
res
}
def clear() {
buffer.clear()
}
def log(level: Level.Value, message: => String) =
if (level == Level.Error) {
buffer += message
}
// we don't log success here
def success(message: => String) = ()
// invoked when a task throws an exception. invoked late, when the exception is logged, i.e.
// just before returning to the prompt. therefore we do nothing: storing the exception in the
// buffer would happen *after* the `handleFailure` reads the buffer.
def trace(t: => Throwable) = ()
}
|