Skip to content

Instantly share code, notes, and snippets.

@sio4
Created October 5, 2014 14:58
Show Gist options
  • Save sio4/319c1e3965470aa2a345 to your computer and use it in GitHub Desktop.
Save sio4/319c1e3965470aa2a345 to your computer and use it in GitHub Desktop.
custom application log for rails app.
# lib/app_logger.rb
# vim: set ts=2 sw=2 expandtab:
class AppLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
LOGGER = AppLogger.new('log/application.log', 'weekly')
# config/enviconment.rb
<...>
require 'app_logger'
<...>
# app/controllers/something_controller.rb
<...>
LOGGER.info "application flow log"
<...>
@sio4
Copy link
Author

sio4 commented Oct 5, 2014

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