[英]display output from a rake task called by SSHKit
我希望能夠從SSHKit調用的rake任務中輸出信息,但是我看不到該怎么做。
說我有以下抽佣任務:
require 'sshkit/dsl'
task :hello => :environment do
puts "Hello world"
end
task :sshkit_hello => :environment do
run_locally do
rake "hello"
end
end
如果我自己運行:hello任務,我會看到“ hello world”語句。 但是,從sshkit任務調用它,我只得到SSHKit信息。 如何從SSHKit調用時出現的第一個rake任務中寫出信息?
rake hello
=> Hello world
rake sshkit_hello
=> INFO [f0857f14] Running /usr/bin/env rake hello on
=> INFO [f0857f14] Finished in 6.107 seconds with exit status 0 (successful).
編輯1:
我發現您可以添加以下內容以獲得基本的終端輸出:
SSHKit.config.output = $stdout
但是,再次輸出的信息是相同的-它告訴您它正在運行“ rake hello”,而不是“ rake hello”的輸出。
rake sshkit_hello
=> rake hello
解決了!
我實際上需要做的是將output_verbosity更改為:debug,以便在第二個rake任務中顯示puts語句:
SSHKit.config.output_verbosity = :debug
rake sshkit_hello
=> INFO [6dd1bbf7] Running bundle exec rake hello on
=> DEBUG [6dd1bbf7] Command: bundle exec rake hello
=> DEBUG [6dd1bbf7] Hello World!
=> INFO [6dd1bbf7] Finished in 6.596 seconds with exit status 0 (successful).
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.