Skip to content

Instantly share code, notes, and snippets.

@blaix
Created February 11, 2009 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaix/62023 to your computer and use it in GitHub Desktop.
Save blaix/62023 to your computer and use it in GitHub Desktop.
# A logger that isn't lame:
class AuditLogger < Logger
def initialize(path_to_logfile)
log_file = File.open(path_to_logfile, 'a')
log_file.sync = true
super(log_file)
end
def format_message(severity, timestamp, progname, msg)
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n"
end
end
# logger = AuditLogger.new("./log/mylog.log")
# logger.info("This will show up right away and not be ugly.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment