Sha256: 4e068101a69a2485d5b415dbd44d1bb018960adae771a3cb911658ba9b18fecd
Contents?: true
Size: 1013 Bytes
Versions: 4
Compression:
Stored size: 1013 Bytes
Contents
module RailsLogstasher # Basically a wrapper for a LogStash event that keeps track of if it was created from a rack # middle-ware or not. This is important when it comes to deciding when to write the log class Event extend Forwardable def_delegators :@logstash_event, :fields, :message=, :source=, :type=, :tags, :to_json def initialize(logger, rack = false) @logger = logger @rack = rack @logstash_event = LogStash::Event.new end def write(rack = false) if @rack @logger.info self if rack else @logger.info self end end def add_tags_to_logger(request, tags) tag_hash = [] if tags tags.each do |tag| case tag when Symbol tag_hash << {tag.to_s => request.send(tag) } when Proc tag_hash << tag.call(request) else tag_hash << tag end end end @logger.push_request_tags(tag_hash) end end end
Version data entries
4 entries across 4 versions & 1 rubygems