如何抑制 sbt 中的信息和成功消息? [英] How to suppress info and success messages in sbt?

查看:57
本文介绍了如何抑制 sbt 中的信息和成功消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 sbt run 时,我看到了一些我想删除的页眉和页脚信息:

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
$ 

我怎样才能去掉那 2 行额外的行(即 [info][success] 行)?是否有一些 build.sbt 配置设置可用于执行此操作?理想情况下,我不想拥有另一个工具/依赖项只是为了摆脱这两行.

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:

  • 将运行日志级别设置为警告
  • 将全局日志级别设置为警告
  • 设置-Dsbt.log.noformat=true

我目前使用的解决方法:复制 sbt 生成的 java 调用(通过执行 pstop)作为执行 的结果fork in run := true 并直接在命令行上手动运行该 java 命令.

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.

如果可以告诉 sbt 不打印这些行,那会最好也更干净.

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

  • Scala 版本:2.9.1
  • SBT 版本:0.11.1

推荐答案

sbt 0.13.13

使用 -warn-error.请参阅具有兼容性影响的修复对于 sbt 0.13.13 版本:

强烈建议迁移到单个连字符选项:-error-warn-info-调试

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

sbt 0.13.1

要禁用 info 消息,请使用 --warn--error 命令行选项运行 SBT.

sbt 0.13.1

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

要禁用 [success] 消息,请将 showSuccess 设置为 false.

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

  • build.sbt 中添加 showSuccess := false

    $ cat build.sbt
    showSuccess := false
    

    并执行sbt --error run.

    这篇关于如何抑制 sbt 中的信息和成功消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆