Module: Padrino::Logger::Colorize

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

Constant Summary

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.

See Also:

  • Padrino::Logging::ColorizedLogger::ColoredLevels


247
248
249
# File 'padrino-core/lib/padrino-core/logger.rb', line 247

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

#stylized_level(level) ⇒ Object



251
252
253
254
# File 'padrino-core/lib/padrino-core/logger.rb', line 251

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