Module: RSMP::Logger::Filtering
- Included in:
- RSMP::Logger
- Defined in:
- lib/rsmp/log/filtering.rb
Overview
Handles filtering logic for log output
Instance Method Summary collapse
- #acknowledgement_enabled?(ack, item) ⇒ Boolean
- #ignorable?(type, ack, item) ⇒ Boolean
- #level_enabled?(item) ⇒ Boolean
- #message_ignored?(item) ⇒ Boolean
- #output?(item, force: false) ⇒ Boolean
Instance Method Details
#acknowledgement_enabled?(ack, item) ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/rsmp/log/filtering.rb', line 36 def acknowledgement_enabled?(ack, item) return true unless ack return true if @settings['acknowledgements'] != false return true if i[not_acknowledged warning error].include?(item[:level]) false end |
#ignorable?(type, ack, item) ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rsmp/log/filtering.rb', line 25 def ignorable?(type, ack, item) @ignorable.each_pair do |key, types| ignore = [types].flatten next unless @settings[key] == false return false if ignore.include?(type) return false if ack && item[:message].original && ignore.include?(item[:message].original.type) end true end |
#level_enabled?(item) ⇒ Boolean
5 6 7 8 9 10 11 12 |
# File 'lib/rsmp/log/filtering.rb', line 5 def level_enabled?(item) return false if @settings['info'] == false && item[:level] == :info return false if @settings['debug'] != true && item[:level] == :debug return false if @settings['statistics'] != true && item[:level] == :statistics return false if @settings['test'] != true && item[:level] == :test true end |
#message_ignored?(item) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rsmp/log/filtering.rb', line 14 def (item) return false unless item[:message] type = item[:message].type ack = %w[MessageAck MessageNotAck].include?(type) return true unless ignorable?(type, ack, item) return true unless acknowledgement_enabled?(ack, item) false end |
#output?(item, force: false) ⇒ Boolean
44 45 46 47 48 49 50 51 |
# File 'lib/rsmp/log/filtering.rb', line 44 def output?(item, force: false) return false if muted?(item) return false if @settings['active'] == false && force != true return false unless level_enabled?(item) return false if (item) true end |