Friday, April 13, 2007

Capistrano logs (See related posts)

To get the last n lines from a remote log file, use this task

Usage: cap log [-s lines=100] [-s rails_env=production]
So, "cap log" returns 100 lines from production.

desc "Returns last lines of log file. Usage: cap log [-s lines=100] [-s rails_env=production]"
task :log do
lines = configuration.variables[:lines] || 100
rails_env = configuration.variables[:rails_env] || 'production'
run "tail -n #{lines} #{app_dir}/log/#{rails_env}.log" do |ch, stream, out|
puts out

No comments :