Revision 790f61f9
Added by Marc Dequènes almost 16 years ago
- ID 790f61f93eb58b1d682eeaa1dcdb7c22dc3cd1a9
lib/cyborghood/base.rb | ||
---|---|---|
class Logger < Log4r::Logger
|
||
include Singleton
|
||
|
||
LOG_FORMAT = "[%5l - %d] %m"
|
||
LOG_FORMAT = "[%5l - %d] #PREFIX#%m"
|
||
|
||
def output_level(level)
|
||
l = case level
|
||
... | ... | |
self.outputters << file_outputter
|
||
end
|
||
|
||
def set_prefix(prefix = "")
|
||
prefix ||= ""
|
||
log_format = LOG_FORMAT.gsub("#PREFIX#", prefix)
|
||
@default_formatter = Log4r::PatternFormatter.new(:pattern => log_format)
|
||
self.outputters.each{|outputter| outputter.formatter = @default_formatter }
|
||
end
|
||
|
||
private
|
||
|
||
def initialize
|
||
super(PRODUCT)
|
||
|
||
self.level = Log4r::DEBUG
|
||
@default_formatter = Log4r::PatternFormatter.new(:pattern => LOG_FORMAT)
|
||
@main_outputter = Log4r::Outputter.stdout
|
||
@main_outputter.formatter = @default_formatter
|
||
@main_outputter.level = Log4r::WARN
|
||
self.outputters = [@main_outputter]
|
||
|
||
set_prefix()
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
[evol] Logger can handle setting a permanent prefix (until reset)