Class: Klogger::JSONHighlighter
- Inherits:
-
Object
- Object
- Klogger::JSONHighlighter
- Defined in:
- lib/klogger/json_highlighter.rb
Defined Under Namespace
Classes: DebugTheme, ErrorTheme, Theme, WarnTheme
Constant Summary collapse
- LEXER =
Rouge::Lexers::JSON.new
- FORMATTER =
Rouge::Formatters::Terminal256
- FORMATTERS =
{ info: FORMATTER.new(Theme.new), debug: FORMATTER.new(DebugTheme.new), warn: FORMATTER.new(WarnTheme.new), error: FORMATTER.new(ErrorTheme.new), fatal: FORMATTER.new(ErrorTheme.new) }.freeze
Class Method Summary collapse
Class Method Details
.highlight(output) ⇒ Object
52 53 54 55 56 |
# File 'lib/klogger/json_highlighter.rb', line 52 def highlight(output) severity = ::Regexp.last_match(1).to_sym if output.match(/"severity":"(\w+)"/) formatter = FORMATTERS[severity] || FORMATTERS[:info] formatter.format(LEXER.lex(output)) end |