I use sbt from within Netbeans. The problem until now was that the
compiler output of sbt was not recognized by Netbeans. In Netbeans
clickable lines must follow a specific pattern:
<absolute file path>:<line>: <explanation>
The output of sbt is:
[info|error|...] <absolute file path>:<line>: explanation
The leading label "[info|error|...] prevents Netbeans from recognizing
these lines. I modified by sbt shellscript the following way:
#!/bin/sh
if [ "$1" = "-modifyOutput" ] ; then
shift
java -Xmx256M -Dsbt.log.noformat=true -jar `dirname $0`/sbt-
launcher.jar "$@" | sed -r -e "s/^[[](debug|info|warn|error)[]] (.+:
[0-9]+:) (.*)/\2 \1: \3/"
else
java -Xmx256M -jar `dirname $0`/sbt-launcher.jar "$@"
fi
Now sed modifies lines which are most likely located messages into the
expected form.
It would be nice if sbt would have a switch to tweak the output format
accordingly. (Maybe the flag sbt.log.noformat could also means that
the log level is not prepended.)
sbt.log.noformat should keep its current meaning, since it is intended for when people want to disable
ansi codes. There are a lot of things that could be tweaked with logging, though, and I'd rather not
cram more into system properties, which I consider to be temporary or subject to change anyway.
The way to do it would be to implement your own logger:
class CustomLogger extends BasicLogger
{
def success(message: => String) = ...
def trace(t: => Throwable) = ...
def log(level: Level.Value, message: => String) = ...
def control(event: ControlEvent.Value, message: => String) = ...
def logAll(events: Seq[LogEvent]) = events.foreach(log)
}
(Yes, logAll and its implementation should be in BasicLogger so you don't have to implement it.)
To use it and override logImpl in your project definition:
override def logImpl = new CustomLogger
or
override def logImpl = new BufferedLogger(new CustomLogger)
if you want it buffered when running a build in parallel.
I haven't published the API documentation for 0.7.0 yet, but you can see the logging related source code
at:
http://github.com/harrah/sbt/blob/using-xsbt/src/main/scala/sbt/Logger.scala
-Mark