Skip to content

Instantly share code, notes, and snippets.

@mikhailov
Created March 25, 2011 06:24
Show Gist options
  • Save mikhailov/886438 to your computer and use it in GitHub Desktop.
Save mikhailov/886438 to your computer and use it in GitHub Desktop.
Capistrano extra recipes
namespace :log do
desc "A pinch of tail"
task :tailf, :roles => :app do
run "tail -n 10000 -f #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
desc "Grep actions and highlight long time actions > 300ms"
task :grep_long, :roles => :app do
run "grep '^Completed' #{shared_path}/log/#{rails_env}.log | tail -n 1000 | perl -pe 's/Completed in ([3-9][0-9]{2,}|1[0-9]{3,})+ms.+]/\e[1;33;44m$&\e[0m/g'" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
# gem install request-log-analyzer
desc "Request-log-analyzer"
task :rla, :roles => :app do
run "request-log-analyzer #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment