Skip to content

Instantly share code, notes, and snippets.

@wevtimoteo
Created January 20, 2015 12:12
Show Gist options
  • Save wevtimoteo/06e2d7e3b8635472c642 to your computer and use it in GitHub Desktop.
Save wevtimoteo/06e2d7e3b8635472c642 to your computer and use it in GitHub Desktop.
Custom logging for ActiveRecord
ActiveRecord::Base.logger = CustomLogger.new(STDOUT)
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