Class: Ktl::ShellFormater

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/ktl/shell_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ ShellFormater

Returns a new instance of ShellFormater.



5
6
7
8
# File 'lib/ktl/shell_formatter.rb', line 5

def initialize(shell)
  @shell = shell
  @padding = ' ' * 2
end

Instance Method Details

#call(severity, time, progname, msg) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ktl/shell_formatter.rb', line 10

def call(severity, time, progname, msg)
  severity_part = sprintf('%-5s', severity.downcase)
  severity_part = @shell.set_color(severity_part, color_for[severity])
  line = %(#{@padding}#{severity_part} #{msg2str(msg)})
  line << NEWLINE unless line.end_with?(NEWLINE)
  line
end