Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress info and success messages in sbt?

Tags:

scala

sbt

When I do sbt run I see some header and footer info which I would like to get rid of:

$ sbt run 
[info] Set current project to XXX (in build file:/path/to/dir/)
<actual program output goes here; stuff I care about>
[success] Total time: 68 s, completed Apr 1, 2012 7:30:45 PM
$ 

How can I get rid of those 2 additional lines (i.e., the [info] and [success] lines)? Are there some build.sbt configuration settings available to do that? Ideally I don't want to have another tool/dependency just to get rid of those 2 lines.

Following is a list of things I have tried:

  • Set run logLevel to Warn
  • Set Global logLevel to Warn
  • Set -Dsbt.log.noformat=true

Workaround that I am currently using: Copy the java invocation that sbt generates (by doing ps or top) as a result of doing fork in run := true and manually run that java command directly on command line.

It would best and much cleaner if sbt can be told not to print those lines.

  • Scala version: 2.9.1
  • SBT version: 0.11.1
like image 830
Arvind K Avatar asked Apr 01 '12 21:04

Arvind K


People also ask

How do I clear my sbt console?

In bash you should be able to use Ctrl+L, on OSX you can also use Cmd+K.

What does sbt clean compile do?

Removes all generated files from the target directory. Compiles source code files that are in src/main/scala, src/main/java, and the root directory of the project. Automatically recompiles source code files while you're running SBT in interactive mode (i.e., while you're at the SBT command prompt).


3 Answers

sbt 1.x, sbt 0.13.13+

Use -warn or -error. See Fixes with compatibility implications for sbt 0.13.13 release:

it is strongly encouraged to migrate to the single hyphen options: -error, -warn, -info, and -debug

sbt 0.13.1

To disable info messages run SBT with --warn or --error command line options.

To disable [success] messages set showSuccess to false.

Bringing it all together, it gives you the following options:

  • On command line use the following:

      $ sbt --error 'set showSuccess := false' run
    
  • In build.sbt add showSuccess := false

      $ cat build.sbt
      showSuccess := false
    

and execute sbt --error run.

like image 171
Jacek Laskowski Avatar answered Oct 21 '22 16:10

Jacek Laskowski


As Jacek mentioned in his response, in build.sbt you can add showSuccess := false to suppress the [success] message. To suppress the [info] message, I'd set the logLevel to Level.Warn for the run configuration only. Putting it together, you want to add these lines to build.sbt:

showSuccess := false

logLevel in run := Level.Warn
like image 41
Adam Dingle Avatar answered Oct 21 '22 14:10

Adam Dingle


You should be able to get rid of the "Set current project" line by adding this to your build.sbt file:

onLoadMessage := ""
like image 4
Seth Tisue Avatar answered Oct 21 '22 16:10

Seth Tisue