Sha256: b400b5cfa93188f85abe807255e78fadf67631a9c6adc384894f0ab7ba33081d

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
logstasher-2.1.5 lib/logstasher/custom_fields.rb
logstasher-2.1.3 lib/logstasher/custom_fields.rb
logstasher-2.1.2 lib/logstasher/custom_fields.rb