Sha256: 45a79afdef555cb08a349500dbbc493e843e2b805b8a5d219b2cb51b60e79167

Contents?: true

Size: 572 Bytes

Versions: 5

Compression:

Stored size: 572 Bytes

Contents

module LogStasher
  module CustomFields
    module LogSubscriber
      def extract_custom_fields(data)
        (!CustomFields.custom_fields.empty? && data.extract!(*CustomFields.custom_fields)) || {}
      end
    end

    def self.clear
      Thread.current[:logstasher_custom_fields] = []
    end

    def self.add(*fields)
      custom_fields.concat(fields).uniq!
    end

    def self.custom_fields
      Thread.current[:logstasher_custom_fields] ||= []
    end

    def self.custom_fields=(val)
      Thread.current[:logstasher_custom_fields] = val
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logstasher-2.1.1 lib/logstasher/custom_fields.rb
logstasher-2.1.0 lib/logstasher/custom_fields.rb
logstasher-2.0.2 lib/logstasher/custom_fields.rb
logstasher-2.0.1 lib/logstasher/custom_fields.rb
logstasher-2.0.0 lib/logstasher/custom_fields.rb