Sha256: 20539d8ad0314da9331800df568932f1ba7a7aabebbd25615ef08107d3bcf29a
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
require "json" require "time" module Log4r module Logstash class JsonFormatter def self.format(logevent, index, data_field_name = "data", level_field_name = "level", additional_fields = {}) data = {} data["type"] = "#{logevent.class}" data["index"] = "#{index}" data["timestamp"] = Time.now.getutc.iso8601 data[level_field_name] = LNAMES[logevent.level] data[data_field_name] = logevent.data.force_encoding("UTF-8") data.merge! eval_map_proc_values(additional_fields) data.to_json end def self.eval_map_proc_values(map) map.each do |key, value| map[key] = value.call if value.class == Proc end map end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
log4r-logstash-0.1.1 | lib/log4r/logstash/formatter/json_formatter.rb |