Class: LogStash::Filters::Empow::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/utils.rb

Constant Summary collapse

TRUTHY_VALUES =
[true, 1, '1']
FALSEY_VALUES =
[false, 0, '0']

Class Method Summary collapse

Class Method Details

.add_error(event, msg) ⇒ Object



25
26
27
# File 'lib/logstash/filters/utils.rb', line 25

def self.add_error(event, msg)
	tag_empow_messages(event, msg, 'empow_errors')
end

.add_warn(event, msg) ⇒ Object



29
30
31
# File 'lib/logstash/filters/utils.rb', line 29

def self.add_warn(event, msg)
	tag_empow_messages(event, msg, 'empow_warnings')
end

.convert_to_boolean(val) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/logstash/filters/utils.rb', line 11

def self.convert_to_boolean(val)
  return nil if val.nil?

  return true if TRUTHY_VALUES.include?(val)

  return false if FALSEY_VALUES.include?(val)

  return true if (val.is_a?(String) and val.downcase.strip == 'true')

  return false if (val.is_a?(String) and val.downcase.strip == 'false')

  return nil
end

.is_blank_string(txt) ⇒ Object



7
8
9
# File 'lib/logstash/filters/utils.rb', line 7

def self.is_blank_string(txt)
  return (txt.nil? or txt.strip.length == 0)
end