Created
August 6, 2010 04:19
-
-
Save fojas/510830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Capistrano task for tailing logs on multiple servers | |
desc "tail log files, use '-s grep=[search text]' and '-s file=[file name]' to grep and tail specific file respectively" | |
task :tail_logs, :roles => :app do | |
set :grep, fetch(:grep, "") | |
set :file, fetch(:file,"~/current/log/production.log") | |
set(:g) { (grep == "") ? "" : " | grep #{grep}" } | |
run "tail -f #{file} #{g}" do |channel, stream, data| | |
#put hostname in front of each line | |
puts "#{data}".gsub( /(^)/i,"#{channel[:host]} \\1") | |
break if stream == :err | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment