17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/bourdain/helpers/logger.rb', line 17
def self.new level=::Logger::INFO, file=STDOUT
logger = ::Logger.new file
logger.level = level
logger.formatter = proc do |severity, datetime, _, msg|
if level == 1
msg.to_s.colorize(
color: SEVERITY_COLORS[severity.to_s][0],
background: SEVERITY_COLORS[severity.to_s][1]
) + "\n"
else
"%s [%s] %s -- %s\n".colorize(
color: SEVERITY_COLORS[severity.to_s][0],
background: SEVERITY_COLORS[severity.to_s][1]
) % [
severity,
datetime.iso8601(6),
File::basename(caller[4]),
msg
]
end
end
return logger
end
|