Class: WEBrick::BasicLog
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/webrick/log.rb |
Overview
A generic logging class
Constant Summary
-
DEBUG =
Debugging error level for messages used in server development or debugging
5
-
ERROR =
Error log level which indicates a recoverable error
2
-
FATAL =
Fatal log level which indicates a server crash
1
-
INFO =
Information log level which indicates possibly useful information
4
-
WARN =
Warning log level which indicates a possible problem
3
Class Method Summary
-
.new(log_file = nil, level = nil) ⇒ BasicLog
constructor
Initializes a new logger for
log_file
that outputs messages at #level or higher.
Instance Attribute Summary
-
#level
rw
log-level, messages above this level will be logged.
-
#debug? ⇒ Boolean
readonly
Will the logger output DEBUG messages?
-
#error? ⇒ Boolean
readonly
Will the logger output ERROR messages?
-
#fatal? ⇒ Boolean
readonly
Will the logger output FATAL messages?
-
#info? ⇒ Boolean
readonly
Will the logger output INFO messages?
-
#warn? ⇒ Boolean
readonly
Will the logger output WARN messages?
Instance Method Summary
-
#<<(obj)
Synonym for log(INFO, obj.to_s).
-
#close
Closes the logger (also closes the log device associated to the logger).
-
#debug(msg)
readonly
Shortcut for logging a DEBUG message.
-
#error(msg)
readonly
Shortcut for logging an ERROR message.
-
#fatal(msg)
readonly
Shortcut for logging a FATAL message.
-
#info(msg)
readonly
Shortcut for logging an INFO message.
-
#log(level, data)
Logs
data
at #level if the given level is above the current log level. -
#warn(msg)
readonly
Shortcut for logging a WARN message.
-
#format(arg)
private
Formats
arg
for the logger.
Constructor Details
.new(log_file = nil, level = nil) ⇒ BasicLog
Instance Attribute Details
#debug? ⇒ Boolean
(readonly)
Will the logger output DEBUG messages?
# File 'lib/webrick/log.rb', line 107
def debug?; @level >= DEBUG; end
#error? ⇒ Boolean
(readonly)
Will the logger output ERROR messages?
# File 'lib/webrick/log.rb', line 101
def error?; @level >= ERROR; end
#fatal? ⇒ Boolean
(readonly)
Will the logger output FATAL messages?
# File 'lib/webrick/log.rb', line 99
def fatal?; @level >= FATAL; end
#info? ⇒ Boolean
(readonly)
Will the logger output INFO messages?
# File 'lib/webrick/log.rb', line 105
def info?; @level >= INFO; end
#level (rw)
log-level, messages above this level will be logged
# File 'lib/webrick/log.rb', line 40
attr_accessor :level
#warn? ⇒ Boolean
(readonly)
Will the logger output WARN messages?
# File 'lib/webrick/log.rb', line 103
def warn?; @level >= WARN; end
Instance Method Details
#<<(obj)
Synonym for log(INFO, obj.to_s)
#close
Closes the logger (also closes the log device associated to the logger)
# File 'lib/webrick/log.rb', line 65
def close @log.close if @opened @log = nil end
#debug(msg) (readonly)
Shortcut for logging a DEBUG message
#error(msg) (readonly)
Shortcut for logging an ERROR message
#fatal(msg) (readonly)
Shortcut for logging a FATAL message
#format(arg) (private)
Formats arg
for the logger
-
If
arg
is an Exception, it will format the error message and the back trace. -
If
arg
responds to#to_str
, it will return it. -
Otherwise it will return
arg
.inspect.
#info(msg) (readonly)
Shortcut for logging an INFO message
#log(level, data)
Logs data
at #level if the given level is above the current log level.
#warn(msg) (readonly)
Shortcut for logging a WARN message