Skip to content

Instantly share code, notes, and snippets.

@davidyang
Created February 8, 2010 18:34
Show Gist options
  • Save davidyang/298427 to your computer and use it in GitHub Desktop.
Save davidyang/298427 to your computer and use it in GitHub Desktop.
class AuditLogger < Logger
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
[:action_controller, :active_record].each do |fw|
fw.to_s.camelize.constantize.const_get("Base").send(:define_method, :audit_log) do
@@audit_log ||= AuditLogger.new(File.open(File.join(RAILS_ROOT, 'log', "audit_#{RAILS_ENV}.log"), 'a'))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment