方法
実行コマンドに--trace
つけるだけだった・・・
capistrano2系だとlog_levelでTRACEとかいうのが指定できるらしいが3系では出来ない様子。
出力内容
** Invoke deploy:xxxxx (first_time)
** Execute deploy:xxxxx
のような感じを区切りに、タスクの実行状況が出力される。
例
cap development deploy:test_task_1 --trace # test_task_1のあとにtest_task_2が走るようなタスク
最初にバリデーション?がガーッと走っている。
** Invoke development (first_time)
** Execute development
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_rails_env
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG[53f4b596] Running /usr/bin/env [ ! -d ~/.rbenv/versions/2.0.0-p451 ] on 192.xxx.xx.xx
DEBUG[53f4b596] Command: [ ! -d ~/.rbenv/versions/2.0.0-p451 ]
DEBUG[53f4b596] Finished in 0.112 seconds with exit status 1 (failed).
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke deploy:test_task_1 (first_time)
** Execute deploy:test_task_1
INFO[1361267d] Running /usr/bin/env echo abcdefg on 192.xxx.xx.xx
DEBUG[1361267d] Command: echo abcdefg
DEBUG[1361267d] abcdefg
INFO[1361267d] Finished in 0.028 seconds with exit status 0 (successful).
** Invoke deploy:test_task_2 (first_time)
** Execute deploy:test_task_2
INFO[ff511f2f] Running /usr/bin/env echo hijklmn on 192.xxx.xx.xx
DEBUG[ff511f2f] Command: echo hijklmn
DEBUG[ff511f2f] hijklmn
INFO[ff511f2f] Finished in 0.032 seconds with exit status 0 (successful).
ファイル出力したい
この画面の出力のままファイルに出力してくれればいいのに、
普通に >
だと、InvokeとExecuteのログが別プロセス?で出力してるらしく、
結局まとまって出力されてしまうので、意味がない!
苦肉の策
script -q -t 0 log.txt cap development deploy:test_task_1 --trace
順番どおりにファイル出力されるようになった!
ただし、capistrano3が色付けしている形跡も一緒に出されてしまうので、非常に見難い。
解決策はまだ見つからない。つらい。