/usr/lib/ruby/1.8/compass/logger.rb is in libcompass-ruby1.8 0.10.6~dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | module Compass
class Logger
DEFAULT_ACTIONS = [:directory, :exists, :remove, :create, :overwrite, :compile, :error, :identical, :warning]
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
ACTION_COLORS = {
:error => :red,
:warning => :yellow,
:compile => :green,
:overwrite => :yellow,
:create => :green,
:remove => :yellow,
:exists => :green,
:directory => :green,
:identical => :green,
:convert => :green
}
attr_accessor :actions, :options
def initialize(*actions)
self.options = actions.last.is_a?(Hash) ? actions.pop : {}
@actions = DEFAULT_ACTIONS.dup
@actions += actions
end
# Record an action that has occurred
def record(action, *arguments)
msg = ""
msg << color(ACTION_COLORS[action]) if Compass.configuration.color_output
msg << "#{action_padding(action)}#{action} #{arguments.join(' ')}"
msg << color(:clear) if Compass.configuration.color_output
log msg
end
def red
$stderr.write(color(:red))
$stdout.write(color(:red))
yield
ensure
$stderr.write(color(:clear))
$stdout.write(color(:clear))
end
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
def emit(msg)
print msg
end
# Emit a log message
def log(msg)
puts msg
end
# add 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.inject(0){|memo, a| [memo, a.to_s.length].max}
end
end
class NullLogger
def record(*args)
end
def log(msg)
end
def red
yield
end
end
end
|