LoginSignup
9
10

More than 5 years have passed since last update.

Rakeタスクのログの書き方

Posted at

Rakeタスクといえどもログでどのように動いているか確認したいときがあります.

Rakeには--trace--verboseのオプションがあり、自作のタスクにもこのオプション次第で詳細を出力したかったので調べてみました.

結果から言うとRake.application.options.traceverboseで判定できます.
traceに関しては専用のメソッドRake.application.traceを使います.

Rake.application.trace "ran with trace" if Rake.application.options.trace
puts "ran with verbose" if verbose

其々のオプションを指定にすると以下のように有効になります.

Option trace verbose
-t, --trace true true
-v, --verbose false true

参考

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10