Class: Kdep::Dashboard::LogPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/kdep/dashboard/log_panel.rb

Constant Summary collapse

MAX_LINES =
500
ERROR_PATTERN =
/\b(ERROR|FATAL|PANIC)\b/
WARN_PATTERN =
/\b(WARN|WARNING)\b/
RED =
"\e[31m".freeze
YELLOW =
"\e[33m".freeze
RESET =
"\e[0m".freeze

Instance Attribute Summary

Attributes inherited from Panel

#lines, #rect, #scroll_offset, #title

Instance Method Summary collapse

Methods inherited from Panel

#initialize, #render, #scroll_down, #scroll_up, #update

Constructor Details

This class inherits a constructor from Kdep::Dashboard::Panel

Instance Method Details

#add_line(line) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kdep/dashboard/log_panel.rb', line 13

def add_line(line)
  was_at_bottom = at_bottom?

  highlighted = highlight(line)
  @lines << highlighted

  # Cap buffer at MAX_LINES
  while @lines.length > MAX_LINES
    @lines.shift
  end

  # Auto-scroll to bottom if we were at bottom
  if was_at_bottom
    scroll_to_bottom
  end
end