Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Easily debug rake task
desc "switch rails logger to stdout"
task :verbose => [:environment] do
Rails.logger = Logger.new(STDOUT)
end
desc "switch rails logger log level to debug"
task :debug => [:environment, :verbose] do
Rails.logger.level = Logger::DEBUG
end
desc "switch rails logger log level to info"
task :info => [:environment, :verbose] do
Rails.logger.level = Logger::INFO
end
@jameslafa
Copy link
Author

jameslafa commented Jul 11, 2016

Add debug.rake in /lib/tasks/debug.rake.

Calling rake debug my_task switch automatically the log level to debug and output in the console.

@repoles
Copy link

repoles commented Jan 9, 2020

Clever! Tks ;)

@gbs4ever
Copy link

gbs4ever commented Nov 6, 2020

very cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment