Created
October 5, 2014 14:58
-
-
Save sio4/319c1e3965470aa2a345 to your computer and use it in GitHub Desktop.
custom application log for rails app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/enviconment.rb | |
| <...> | |
| require 'app_logger' | |
| <...> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/controllers/something_controller.rb | |
| <...> | |
| LOGGER.info "application flow log" | |
| <...> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.ruby-doc.org/stdlib-2.1.3/libdoc/logger/rdoc/Logger.html