Module: Captive::LogUtils::LogLevelDetector
- Defined in:
- lib/captive/log_utils/log_level_detector.rb
Class Method Summary collapse
Class Method Details
.call(text) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/captive/log_utils/log_level_detector.rb', line 8 def self.call(text) json = JSON.parse(text) level = (json["level"] || json["severity"] || "").downcase case level when /error|fatal/ then "error" when /warn/ then "warn" when /debug/ then "debug" else "info" end rescue JSON::ParserError, TypeError case text when /\b(ERROR|FATAL)\b/i then "error" when /\bWARN\b/i then "warn" when /\bDEBUG\b/i then "debug" else "info" end end |