Module: Log::Filter

Included in:
Log
Defined in:
lib/log/filter.rb

Instance Method Summary collapse

Instance Method Details

#log_all_tags?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/log/filter.rb', line 47

def log_all_tags?
  logger_tag?(:_all)
end

#log_untagged?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/log/filter.rb', line 51

def log_untagged?
  logger_tag?(:_untagged)
end

#precedent?(message_level) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/log/filter.rb', line 15

def precedent?(message_level)
  ordinal(message_level) <= logger_ordinal
end

#tags_intersect?(message_tags) ⇒ Boolean Also known as: logger_tags_intersect?

Returns:

  • (Boolean)


55
56
57
58
59
60
61
# File 'lib/log/filter.rb', line 55

def tags_intersect?(message_tags)
  if !(message_tags & logger_excluded_tags).empty?
    return false
  end

  !(logger_included_tags & message_tags).empty?
end

#write_level?(message_level) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
# File 'lib/log/filter.rb', line 3

def write_level?(message_level)
  if message_level.nil? && !logger_level?
    return true
  end

  if message_level.nil? || !logger_level?
    return false
  end

  precedent?(message_level)
end

#write_tag?(message_tags) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/log/filter.rb', line 19

def write_tag?(message_tags)
  message_tags ||= []

  if message_tags.empty? && !logger_tags?
    return true
  end

  if message_tags.include?(:*)
    return true
  end

  if log_all_tags?
    return true
  end

  if message_tags.empty? && log_untagged?
    return true
  end

  if !message_tags.empty? && logger_tags?
    if logger_tags_intersect?(message_tags)
      return true
    end
  end

  false
end