Module: Padrino::Logger::Colorize

Defined in:
padrino-core/lib/padrino-core/logger.rb

Constant Summary collapse

ColoredLevels =

Colors for levels

{
  :fatal => [:bold, :red],
  :error => [:default, :red],
  :warn  => [:default, :yellow],
  :info  => [:default, :green],
  :debug => [:default, :cyan],
  :devel => [:default, :magenta]
}

Instance Method Summary collapse

Instance Method Details

#colorize(string, *colors) ⇒ Object

Colorize our level.

Parameters:

See Also:

  • Padrino::Logging::ColorizedLogger::ColoredLevels


256
257
258
# File 'padrino-core/lib/padrino-core/logger.rb', line 256

def colorize(string, *colors)
  string.colorize(:color => colors[0], :mode => colors[1])
end

#stylized_level(level) ⇒ Object



260
261
262
263
# File 'padrino-core/lib/padrino-core/logger.rb', line 260

def stylized_level(level)
  style = "\e[%d;%dm" % ColoredLevels[level].map{|color| String::Colorizer.modes[color] || String::Colorizer.colors[color] }
  [style, super, "\e[0m"] * ''
end