Class: Logfmtr::LogfmtLogger
- Inherits:
-
Object
- Object
- Logfmtr::LogfmtLogger
- Defined in:
- lib/logfmtr/base.rb
Instance Method Summary collapse
- #call(severity, datetime, progname, msg) ⇒ Object
-
#initialize(datetime_format = nil) ⇒ LogfmtLogger
constructor
A new instance of LogfmtLogger.
Constructor Details
#initialize(datetime_format = nil) ⇒ LogfmtLogger
Returns a new instance of LogfmtLogger.
3 4 5 |
# File 'lib/logfmtr/base.rb', line 3 def initialize(datetime_format=nil) @datetime_format = datetime_format || "%Y-%m-%d %H:%M:%S %z" end |
Instance Method Details
#call(severity, datetime, progname, msg) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/logfmtr/base.rb', line 7 def call(severity, datetime, progname, msg) if msg.is_a? Hash msg_str = logfmtify_hash(msg) else msg_str = %Q[msg=#{add_quotes(msg)}] end %Q[level=#{severity} datetime="#{datetime.strftime(@datetime_format)}" progname=#{progname} #{msg_str}\n] end |