Class: Kenny::Formatters::LogStashFormatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- Kenny::Formatters::LogStashFormatter
- Defined in:
- lib/kenny/formatters/log_stash_formatter.rb
Overview
Formats messages as LogStash::Event the ‘type’ field can be used for ElasticSearch The ‘type’ could be set through the Logger’s progname, which takes the highest precedence. If logger.progname.nil?, it will take the ‘type’ within the hash. If the ‘type’ within the Hash is also nil, then you can set the type through FileBeat’s config
Instance Method Summary collapse
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/kenny/formatters/log_stash_formatter.rb', line 15 def call(severity, time, progname, msg) msg = { 'message' => msg.is_a?(String) ? msg : msg.inspect } unless msg.is_a?(Hash) msg['severity'] = severity if severity msg['type'] = progname if progname event = LogStash::Event.new(msg) "%s\n" % event.to_json end |