Sha256: d42af9d43bf046bd9d25120149bf04cbc67cd077cb88ee67b0cdda37156dd759
Contents?: true
Size: 865 Bytes
Versions: 1
Compression:
Stored size: 865 Bytes
Contents
require 'logger' require 'logstash-event' require 'active_support' module Kenny module Formatters ## # 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 class LogStashFormatter < ::Logger::Formatter 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kenny-0.1.4 | lib/kenny/formatters/log_stash_formatter.rb |