Suppress Output in Rake Task db:schema:load

后端 未结 2 461
走了就别回头了
走了就别回头了 2020-12-18 00:11

How can you suppress the output of db:load:schema? Running

bundle exec rake db:schema:load

with the -s, -q, or ev

2条回答
  •  时光取名叫无心
    2020-12-18 00:44

    Here is a cleaner solution that works cross-system:

    silence_stream(STDOUT) do
      # anything written to STDOUT here will be silenced
      Rake::Task["db:schema:load"].invoke
    end
    

    also

    quietly do
      # anything written to STDOUT or STDERR here will be silenced
      Rake::Task["db:schema:load"].invoke
    end
    

    I prefer silence_stream(STDOUT) toquietly because it will still allow error messages written to STDERR to be shown, which will be helpful when the rake command starts to act up.

    References: silence_stream, silence_warnings, & quietly

提交回复
热议问题