Display timestamp for debug mode in SBT?

My sbt update is very slow, I would like to see what will be in the details.

So, I have a:

sbt --debug update > sbtupdate.log 

The problem is that there is no time stamp for each line in the log, how do I enable it?

+2
sbt
source share
2 answers

As far as I know, this is not possible using only SBT parameters. However, this question provides a good solution. I will rephrase the answer for your specific case. All of the following assumes Unix, but it can be adapted for the Windows environment (and simply if you use Cygwin).

First you need a script called for the predate.sh example, which contains:

 #!/bin/bash while read line ; do echo "$(date): ${line}" done 

The date command can be customized to suit your needs. Then you must make this script executable using chmod u+x predate.sh .

Finally, run your initial command and submit standard output to our new script:

 sbt --debug update | ./predate.sh > sbtupdate.log 

Please read the related question, it contains interesting other answers.

+1
source share

I think you need to develop your own logger as described in Add a custom log :

The extraLoggers parameter can be used to add custom registrars. The custom logger should implement [AbstractLogger]. extraLoggers is a function of ScopedKey [_] => Seq [AbstractLogger]. This means that it can provide different logging based on the task requested by the registrar.

In the user logger, you add messages with a timestamp.

 def datedPrintln = (m: String) => println(s"+++ ${java.util.Calendar.getInstance().getTime()} $m") extraLoggers := { val clientLogger = FullLogger { new Logger { def log(level: Level.Value, message: => String): Unit = if(level >= Level.Info) datedPrintln(s"$message at $level") def success(message: => String): Unit = datedPrintln(s"success: $message") def trace(t: => Throwable): Unit = datedPrintln(s"trace: throwable: $t") } } val currentFunction = extraLoggers.value (key: ScopedKey[_]) => clientLogger +: currentFunction(key) } 

Can you learn about how to develop your own journal in my response to Custom extraLogger not receiving [successful] messages in sbt?

+1
source share

All Articles