Created
January 20, 2015 12:12
-
-
Save wevtimoteo/06e2d7e3b8635472c642 to your computer and use it in GitHub Desktop.
Custom logging for ActiveRecord
This file contains 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
ActiveRecord::Base.logger = CustomLogger.new(STDOUT) |
This file contains 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
class CustomLogger < Logger | |
def format_message(severity, timestamp, progname, msg) | |
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" | |
end | |
end | |
logfile = File.open('/path/to/custom.log', 'a') | |
custom_logger = CustomLogger.new(logfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment