Sha256: daba1a51404df0ae43ca7c4d2fa2b03246604f2ae3640317a73052e55a6086cd

Contents?: true

Size: 935 Bytes

Versions: 12

Compression:

Stored size: 935 Bytes

Contents

# frozen_string_literal: true

module Logster
  class SuppressionPattern < Pattern
    CACHE_KEY = :suppression
    def self.set_name
      "__LOGSTER__suppression_patterns_set".freeze
    end

    def save(args = {})
      super
      @store.clear_patterns_cache(CACHE_KEY)
      retro_delete_messages if args[:retroactive]
    end

    def destroy(clear_cache: true) # arg used in tests
      super()
      @store.remove_ignore_count(self.to_s)
      @store.clear_patterns_cache(CACHE_KEY) if clear_cache
    end

    private

    def retro_delete_messages
      keys = []
      grouping_keys = []
      @store
        .get_all_messages(with_env: false)
        .each do |message|
          if message =~ self.pattern
            keys << message.key
            grouping_keys << message.grouping_key
          end
        end
      @store.bulk_delete(keys, grouping_keys) if keys.size > 0 && grouping_keys.size > 0
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
logster-2.20.0 lib/logster/suppression_pattern.rb
logster-2.19.1 lib/logster/suppression_pattern.rb
logster-2.19.0 lib/logster/suppression_pattern.rb
logster-2.18.1 lib/logster/suppression_pattern.rb
logster-2.18.0 lib/logster/suppression_pattern.rb
logster-2.17.1 lib/logster/suppression_pattern.rb
logster-2.17.0 lib/logster/suppression_pattern.rb
logster-2.16.0 lib/logster/suppression_pattern.rb
logster-2.15.0 lib/logster/suppression_pattern.rb
logster-2.14.0 lib/logster/suppression_pattern.rb
logster-2.13.1 lib/logster/suppression_pattern.rb
logster-2.13.0 lib/logster/suppression_pattern.rb