Module: Collins::Api::Logging::Severity
Overview
Constant Summary collapse
- EMERGENCY =
"EMERGENCY"
- ALERT =
"ALERT"
- CRITICAL =
"CRITICAL"
- ERROR =
"ERROR"
- WARNING =
"WARNING"
- NOTICE =
"NOTICE"
- INFORMATIONAL =
"INFORMATIONAL"
- DEBUG =
"DEBUG"
- NOTE =
"NOTE"
Instance Method Summary collapse
-
#normalize(level) ⇒ Symbol
Convert a level into one appropriate for validating.
-
#to_a ⇒ Array<String>
Severity levels.
-
#valid?(level) ⇒ Boolean
Check is a level is valid or not.
-
#value_of(level) ⇒ String
Given a severity level, give back the severity, or nil if not valid.
Instance Method Details
#normalize(level) ⇒ Symbol
Convert a level into one appropriate for validating
38 39 40 |
# File 'lib/collins/api/logging.rb', line 38 def normalize level level.to_s.upcase.to_sym end |
#to_a ⇒ Array<String>
Returns severity levels.
51 52 53 54 |
# File 'lib/collins/api/logging.rb', line 51 def to_a s = Collins::Api::Logging::Severity s.constants.map{|c| s.const_get(c)} end |
#valid?(level) ⇒ Boolean
Check is a level is valid or not
45 46 47 48 |
# File 'lib/collins/api/logging.rb', line 45 def valid? level level_s = normalize level Collins::Api::Logging::Severity.constants.include?(level_s) end |
#value_of(level) ⇒ String
Given a severity level, give back the severity, or nil if not valid
26 27 28 29 30 31 32 33 |
# File 'lib/collins/api/logging.rb', line 26 def value_of level level_s = normalize level if valid? level_s then level_s.to_s else nil end end |