Module: Padrino::Logger::Colorize

Defined in:
lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/logger.rb

Constant Summary collapse

ColoredLevels =

Colors for levels

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

Instance Method Summary collapse

Instance Method Details

#colorize(string, *colors) ⇒ Object

Colorize our level

Parameters:

See Also:

  • Padrino::Logging::ColorizedLogger::ColoredLevels


195
196
197
198
199
200
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/logger.rb', line 195

def colorize(string, *colors)
  colors.each do |c|
    string = string.send(c)
  end
  string
end

#stylized_level(level) ⇒ Object



202
203
204
205
# File 'lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/logger.rb', line 202

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