Class: AlpacaBuildTool::RainbowifyLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/alpacabuildtool/log/rainbowify_logger.rb

Overview

RainbowifyLogger class is extending ruby logger with header and puts methods and add colors to logs

Constant Summary collapse

SEVERITIES =

Custom severities that current logger support

%w(DEBUG INFO WARN ERROR FATAL PUTS HEADER)

Instance Method Summary collapse

Constructor Details

#initializeRainbowifyLogger

Creates instance of logger with STDOUT as IO object for logger and adds RainbowifyFormatter as a formatter

Creates ruby logger with STDOUT object and rainbowify formatter


18
19
20
21
# File 'lib/alpacabuildtool/log/rainbowify_logger.rb', line 18

def initialize
  super(STDOUT)
  @formatter = RainbowifyFormatter.new
end

Instance Method Details

#format_severity(severity) ⇒ Object

Override logger.format_severity in order to use our own severities


25
26
27
# File 'lib/alpacabuildtool/log/rainbowify_logger.rb', line 25

def format_severity(severity)
  SEVERITIES[severity] || 'ANY'
end

#header(progname = nil, &block) ⇒ Object

Log nice ASCII art styled header

progname

program name

accepts &block


43
44
45
# File 'lib/alpacabuildtool/log/rainbowify_logger.rb', line 43

def header(progname = nil, &block)
  add(6, nil, progname, &block)
end

#puts(progname = nil, &block) ⇒ Object

Log nice ASCII art styled header

progname

program name

accepts &block


34
35
36
# File 'lib/alpacabuildtool/log/rainbowify_logger.rb', line 34

def puts(progname = nil, &block)
  add(5, nil, progname, &block)
end