Skip to content

Instantly share code, notes, and snippets.

@linjian
Created July 19, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linjian/3141367 to your computer and use it in GitHub Desktop.
Save linjian/3141367 to your computer and use it in GitHub Desktop.
Puts to Log
# Add the following line to config/environments/development.rb or config/initializers/
# So I can use puts or p to print debug message to log file when I use nginx, which has no way to see STDOUT directly.
if Rails.env.development? && $PROGRAM_NAME !~ /script\/rails/ && $PROGRAM_NAME !~ /rake/
STDOUT.reopen(File.open("#{Rails.root}/log/development.log", 'a+'))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment