105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/dr/logger.rb', line 105
def self.log(msg_type, msg, verbosity=nil)
out = "dr".style("log-head") << " "
case msg_type
when :info
out << "info".style(@@message_types[:info])
verbosity = :informative unless verbosity
when :warn
out << "WARN".style(@@message_types[:warn])
verbosity = :informative unless verbosity
when :err
out << "ERR!".style(@@message_types[:err])
verbosity = :essential unless verbosity
when :debug
out << "dbg?".style(@@message_types[:debug])
verbosity = :verbose unless verbosity
end
if verbosity <= @@verbosity
out << " " << msg.chomp
puts out
STDOUT.flush
unless @@log_file.nil?
@@log_file.puts strip_colours out
@@log_file.flush
end
end
end
|