Class: Dry::Logger::Filter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/logger/filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Filtering logic Originaly copied from hanami/utils (see Hanami::Logger)

Instance Method Summary collapse

Constructor Details

#initialize(filters = []) ⇒ Filter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Filter.



11
12
13
# File 'lib/dry/logger/filter.rb', line 11

def initialize(filters = [])
  @filters = filters
end

Instance Method Details

#call(hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
25
# File 'lib/dry/logger/filter.rb', line 16

def call(hash)
  hash = _deep_dup(hash)

  _filtered_keys(hash).each do |key|
    *keys, last = _actual_keys(hash, key.split("."))
    keys.inject(hash, :fetch)[last] = "[FILTERED]"
  end

  hash
end