Module: Pwrake::Log
- Defined in:
- lib/pwrake/logger.rb
Constant Summary
collapse
- @@logger =
nil
Class Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth_id, *args) ⇒ Object
35
36
37
38
39
|
# File 'lib/pwrake/logger.rb', line 35
def method_missing(meth_id,*args)
if @@logger
@@logger.send(meth_id,*args)
end
end
|
Class Method Details
.bt(e) ⇒ Object
41
42
43
|
# File 'lib/pwrake/logger.rb', line 41
def bt(e)
"#{e.class}: #{e.message}\n "+(e.backtrace||[]).join("\n ")
end
|
.method_missing(meth_id, *args) ⇒ Object
35
36
37
38
39
|
# File 'lib/pwrake/logger.rb', line 35
def method_missing(meth_id,*args)
if @@logger
@@logger.send(meth_id,*args)
end
end
|
.set_logger(option) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/pwrake/logger.rb', line 11
def set_logger(option)
unless @@logger
if logdir = option['LOG_DIR']
::FileUtils.mkdir_p(logdir)
logfile = File.join(logdir, option['LOG_FILE'])
@@logger = Logger.new(logfile)
else
if option['DEBUG']
@@logger = Logger.new($stderr)
else
@@logger = Logger.new(File::NULL)
end
end
if option['DEBUG']
@@logger.level = Logger::DEBUG
else
@@logger.level = Logger::INFO
end
at_exit{@@logger.close}
end
end
|