Sha256: 14daf3a7a9447dca5f1db9191a979b09231bd2cbd278cf0bb3ca028506b70c56
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
# ~*~ encoding: utf-8 ~*~ require 'active_support/core_ext/logger' module Spirit # @see https://github.com/chriseppstein/compass/blob/stable/lib/compass/logger.rb class Logger < ::Logger COLORS = { clear: 0, red: 31, green: 32, blue: 35, yellow: 33, grey: 37 } ACTION_COLORS = { :error => :red, :warning => :yellow, :problem => :blue, } # Record that an action has occurred. def record(action, *args) msg = '' msg << color(ACTION_COLORS[action]) msg << action_padding(action) + action.to_s msg << color(:clear) msg << ' ' + args.join(' ') info msg end private def color(c) (c and code = COLORS[c.to_sym]) ? "\e[#{code}m" : '' end # Adds padding to the left of an action that was performed. def action_padding(action) ' ' * [(max_action_length - action.to_s.length), 0].max end # the maximum length of all the actions known to the logger. def max_action_length @max_action_length ||= actions.reduce(0) { |m, a| [m, a.to_s.length].max } end def actions @actions ||= ACTION_COLORS.keys end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spirit-0.2 | lib/spirit/logger.rb |
spirit-0.1.0.pre.2 | lib/spirit/logger.rb |
spirit-0.1.0.pre.1 | lib/spirit/logger.rb |
spirit-0.1.0.pre | lib/spirit/logger.rb |