Class: Autowow::LogFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/autowow/log_formatter.rb

Class Method Summary collapse

Class Method Details

.beautify(severity, msg) ⇒ Object



5
6
7
8
9
# File 'lib/autowow/log_formatter.rb', line 5

def self.beautify(severity, msg)
  log_msg = msg.to_s.end_with?($/) ? msg : "#{msg}#{$/}"
  log_msg = " $ #{log_msg}" if severity.eql?("DEBUG")
  color(severity, log_msg)
end

.color(severity, msg) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/autowow/log_formatter.rb', line 11

def self.color(severity, msg)
  pastel = Pastel.new
  case severity
  when "DEBUG"
    pastel.yellow(msg)
  when "WARN"
    pastel.red(msg)
  when "ERROR"
    pastel.bright_red(msg)
  else
    msg
  end
end