Parent

Class/Module Index [+]

Quicksearch

Compass::Logger

Attributes

actions[RW]
options[RW]
time[RW]

Public Class Methods

new(*actions) click to toggle source
# File lib/compass/logger.rb, line 53
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 120
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 95
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

Emit a log message without a trailing newline

# File lib/compass/logger.rb, line 108
def emit(msg)
  print msg
  $stdout.flush
end
green() click to toggle source
# File lib/compass/logger.rb, line 73
def green
  wrap(:green) { yield }
end
log(msg) click to toggle source

Emit a log message with a trailing newline

# File lib/compass/logger.rb, line 114
def log(msg)
  puts msg
  $stdout.flush
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 125
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 60
def record(action, *arguments)
  return if options[:quiet] && ACTION_CAN_BE_QUIET[action]
  msg = ""
  if time
    msg << Time.now.strftime("%I:%M:%S.%3N %p")
  end
  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 77
def red
  wrap(:red) { yield }
end
wrap(c, reset_to = :clear) click to toggle source
# File lib/compass/logger.rb, line 85
def wrap(c, reset_to = :clear)
  $stderr.write(color(c))
  $stdout.write(color(c))
  yield
ensure
  $stderr.write(color(reset_to))
  $stdout.write(color(reset_to))
  $stdout.flush
end
yellow() click to toggle source
# File lib/compass/logger.rb, line 81
def yellow
  wrap(:yellow) { yield }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.