class Compass::Logger
Constants
- ACTION_COLORS
- COLORS
- DEFAULT_ACTIONS
Attributes
actions[RW]
options[RW]
Public Class Methods
new(*actions)
click to toggle source
# File lib/compass/logger.rb, line 26 def initialize(*actions) self.options = actions.last.is_a?(Hash) ? actions.pop : {} @actions = DEFAULT_ACTIONS.dup @actions += actions end
Public Instance Methods
action_padding(action)
click to toggle source
add padding to the left of an action that was performed.
# File lib/compass/logger.rb, line 82 def action_padding(action) ' ' * [(max_action_length - action.to_s.length), 0].max end
color(c)
click to toggle source
# File lib/compass/logger.rb, line 60 def color(c) if Compass.configuration.color_output && c && COLORS.has_key?(c.to_sym) if defined?($boring) && $boring "" else "\e[#{COLORS[c.to_sym]}m" end else "" end end
emit(msg)
click to toggle source
# File lib/compass/logger.rb, line 72 def emit(msg) print msg end
log(msg)
click to toggle source
Emit a log message
# File lib/compass/logger.rb, line 77 def log(msg) puts msg end
max_action_length()
click to toggle source
the maximum length of all the actions known to the logger.
# File lib/compass/logger.rb, line 87 def max_action_length @max_action_length ||= actions.inject(0){|memo, a| [memo, a.to_s.length].max} end
record(action, *arguments)
click to toggle source
Record an action that has occurred
# File lib/compass/logger.rb, line 33 def record(action, *arguments) msg = "" msg << color(ACTION_COLORS[action]) if Compass.configuration.color_output msg << "#{action_padding(action)}#{action}" msg << color(:clear) if Compass.configuration.color_output msg << " #{arguments.join(' ')}" log msg end
red() { || ... }
click to toggle source
# File lib/compass/logger.rb, line 42 def red $stderr.write(color(:red)) $stdout.write(color(:red)) yield ensure $stderr.write(color(:clear)) $stdout.write(color(:clear)) end
yellow() { || ... }
click to toggle source
# File lib/compass/logger.rb, line 51 def yellow $stderr.write(color(:yellow)) $stdout.write(color(:yellow)) yield ensure $stderr.write(color(:clear)) $stdout.write(color(:clear)) end