Sha256: fcde74d8bd653fbcc3c7b03e9898800809ad02885eb46ccc195c9620fbf04c59
Contents?: true
Size: 604 Bytes
Versions: 2
Compression:
Stored size: 604 Bytes
Contents
require 'nypl_log_formatter/version' require 'logger' require 'json' class NyplLogFormatter < ::Logger include NyplLogFormatterVersion def initialize(*args) super(*args) # This has to happen _after_ call to super, otherwise ::Logger will set the formatter set_formatter end private def set_formatter self.formatter = proc do |severity, datetime, progname, msg| message_hash = { level: severity.upcase, message: msg, timestamp: Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%z") } "#{JSON.generate(message_hash)}\n" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nypl_log_formatter-0.1.1 | lib/nypl_log_formatter.rb |
nypl_log_formatter-0.1.0 | lib/nypl_log_formatter.rb |