Class: WEBrick::Log
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
BasicLog
|
|
Instance Chain:
self,
BasicLog
|
|
Inherits: |
WEBrick::BasicLog
|
Defined in: | lib/webrick/log.rb |
Overview
A logging class that prepends a timestamp to each message.
Constant Summary
Class Method Summary
-
.new(log_file = nil, level = nil) ⇒ Log
constructor
Same as
BasicLog#initialize
BasicLog
- Inherited
.new | Initializes a new logger for |
Instance Attribute Summary
-
#time_format
rw
Format of the timestamp which is applied to each logged line.
BasicLog
- Inherited
Instance Method Summary
-
#log(level, data)
Same as BasicLog#log
BasicLog
- Inherited
#<< | Synonym for log(INFO, obj.to_s). |
#close | Closes the logger (also closes the log device associated to the logger). |
#debug | Shortcut for logging a DEBUG message. |
#error | Shortcut for logging an ERROR message. |
#fatal | Shortcut for logging a FATAL message. |
#info | Shortcut for logging an INFO message. |
#log | Logs |
#warn | Shortcut for logging a WARN message. |
#format | Formats |
Constructor Details
.new(log_file = nil, level = nil) ⇒ Log
Same as BasicLog#initialize
You can set the timestamp format through #time_format
# File 'lib/webrick/log.rb', line 143
def initialize(log_file=nil, level=nil) super(log_file, level) @time_format = "[%Y-%m-%d %H:%M:%S]" end
Instance Attribute Details
#time_format (rw)
Format of the timestamp which is applied to each logged line. The default is "[%Y-%m-%d %H:%M:%S]"
# File 'lib/webrick/log.rb', line 137
attr_accessor :time_format
Instance Method Details
#log(level, data)
Same as BasicLog#log
# File 'lib/webrick/log.rb', line 150
def log(level, data) tmp = Time.now.strftime(@time_format) tmp << " " << data super(level, tmp) end