Sha256: 8740e6877a2f587ccb6b8aff8bf7a084a11522cdc2c818afbf72f8317d5036a0

Contents?: true

Size: 554 Bytes

Versions: 3

Compression:

Stored size: 554 Bytes

Contents

require 'logger'
require 'colorize'
module Populus
  class DefaultLoggerFormatter < ::Logger::Formatter
    COLOR_CODE = {
      'DEBUG' => :black,
      'INFO'  => :green,
      'WARN'  => :yellow,
      'ERROR' => :red,
      'FATAL' => :magenta,
    }

    def call(severity, time, progname, msg)
      s = super
      s[0] = ("%5s" % severity).colorize(:color => COLOR_CODE[severity])
      s
    end
  end

  logger = ::Logger.new(STDOUT)
  logger.level = ::Logger::DEBUG
  logger.formatter = DefaultLoggerFormatter.new
  DefaultLogger = logger
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
populus-0.0.4 lib/populus/default_logger.rb
populus-0.0.3 lib/populus/default_logger.rb
populus-0.0.1 lib/populus/default_logger.rb