In Files
- webrick/log.rb
Parent
Class/Module Index
- Dir
- Errno
- Errno::ECONNABORTED
- Errno::ECONNRESET
- Errno::EPROTO
- File
- Object
- WEBrick
- WEBrick::AccessLog
- WEBrick::AccessLog::AccessLogError
- WEBrick::BasicLog
- WEBrick::CGI
- WEBrick::Config
- WEBrick::Config::OpenSSL
- WEBrick::Cookie
- WEBrick::Daemon
- WEBrick::GenericServer
- WEBrick::HTMLUtils
- WEBrick::HTTPAuth
- WEBrick::HTTPAuth::Authenticator
- WEBrick::HTTPAuth::BasicAuth
- WEBrick::HTTPAuth::DigestAuth
- WEBrick::HTTPAuth::Htdigest
- WEBrick::HTTPAuth::Htgroup
- WEBrick::HTTPAuth::Htpasswd
- WEBrick::HTTPAuth::ProxyAuthenticator
- WEBrick::HTTPAuth::ProxyBasicAuth
- WEBrick::HTTPAuth::ProxyDigestAuth
- WEBrick::HTTPAuth::UserDB
- WEBrick::HTTPProxyServer
- WEBrick::HTTPRequest
- WEBrick::HTTPResponse
- WEBrick::HTTPServer
- WEBrick::HTTPServerError
- WEBrick::HTTPServlet
- WEBrick::HTTPServlet::AbstractServlet
- WEBrick::HTTPServlet::CGIHandler
- WEBrick::HTTPServlet::DefaultFileHandler
- WEBrick::HTTPServlet::ERBHandler
- WEBrick::HTTPServlet::FileHandler
- WEBrick::HTTPServlet::HTTPServletError
- WEBrick::HTTPServlet::ProcHandler
- WEBrick::HTTPStatus
- WEBrick::HTTPStatus::ClientError
- WEBrick::HTTPStatus::EOFError
- WEBrick::HTTPStatus::Error
- WEBrick::HTTPStatus::Info
- WEBrick::HTTPStatus::Redirect
- WEBrick::HTTPStatus::ServerError
- WEBrick::HTTPStatus::Status
- WEBrick::HTTPStatus::Success
- WEBrick::HTTPUtils
- WEBrick::HTTPUtils::FormData
- WEBrick::HTTPVersion
- WEBrick::Log
- WEBrick::ServerError
- WEBrick::SimpleServer
- WEBrick::Utils
- WEBrick::Utils::TimeoutHandler
- WEBrick::Utils::TimeoutHandler::Thread
WEBrick::BasicLog
A generic logging class
Constants
- DEBUG
Debugging error level for messages used in server development or debugging
- ERROR
Error log level which indicates a recoverable error
- FATAL
Fatal log level which indicates a server crash
- INFO
Information log level which indicates possibly useful information
- WARN
Warning log level which indicates a possible problem
Public Class Methods
Initializes a new logger for log_file
that outputs messages at
level
or higher. log_file
can be a filename, an
IO-like object that responds to << or nil which outputs to $stderr.
If no level is given INFO is chosen by default
# File webrick/log.rb, line 50 def initialize(log_file=nil, level=nil) @level = level || INFO case log_file when String @log = open(log_file, "a+") @log.sync = true @opened = true when NilClass @log = $stderr else @log = log_file # requires "<<". (see BasicLog#log) end end
Public Instance Methods
Synonym for log(INFO, obj.to_s)
# File webrick/log.rb, line 84 def <<(obj) log(INFO, obj.to_s) end
Closes the logger (also closes the log device associated to the logger)
# File webrick/log.rb, line 66 def close @log.close if @opened @log = nil end
Shortcut for logging a DEBUG message
# File webrick/log.rb, line 97 def debug(msg) log(DEBUG, "DEBUG " << format(msg)); end
Will the logger output DEBUG messages?
# File webrick/log.rb, line 108 def debug?; @level >= DEBUG; end
Shortcut for logging an ERROR message
# File webrick/log.rb, line 91 def error(msg) log(ERROR, "ERROR " << format(msg)); end
Will the logger output ERROR messages?
# File webrick/log.rb, line 102 def error?; @level >= ERROR; end
Shortcut for logging a FATAL message
# File webrick/log.rb, line 89 def fatal(msg) log(FATAL, "FATAL " << format(msg)); end
Will the logger output FATAL messages?
# File webrick/log.rb, line 100 def fatal?; @level >= FATAL; end
Shortcut for logging an INFO message
# File webrick/log.rb, line 95 def info(msg) log(INFO, "INFO " << format(msg)); end
Will the logger output INFO messages?
# File webrick/log.rb, line 106 def info?; @level >= INFO; end
Logs data
at level
if the given level is above
the current log level.
# File webrick/log.rb, line 75 def log(level, data) if @log && level <= @level data += "\n" if /\n\Z/ !~ data @log << data end end
Shortcut for logging a WARN message
# File webrick/log.rb, line 93 def warn(msg) log(WARN, "WARN " << format(msg)); end
Will the logger output WARN messages?
# File webrick/log.rb, line 104 def warn?; @level >= WARN; end