This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
module WEBrick
|
||||
class BasicLog
|
||||
@log: IO?
|
||||
|
||||
@opened: TrueClass?
|
||||
|
||||
FATAL: 1
|
||||
|
||||
ERROR: 2
|
||||
|
||||
WARN: 3
|
||||
|
||||
INFO: 4
|
||||
|
||||
DEBUG: 5
|
||||
|
||||
# log-level, messages above this level will be logged
|
||||
attr_accessor level: Integer
|
||||
|
||||
type log_file = (IO | String)?
|
||||
|
||||
def initialize: (?log_file log_file, ?Integer? level) -> void
|
||||
|
||||
#
|
||||
# Closes the logger (also closes the log device associated to the logger)
|
||||
def close: () -> void
|
||||
|
||||
def log: (Integer level, String data) -> IO?
|
||||
|
||||
#
|
||||
# Synonym for log(INFO, obj.to_s)
|
||||
def <<: (_ToS obj) -> IO?
|
||||
|
||||
type message = Exception | _ToStr | Object
|
||||
|
||||
# Shortcut for logging a FATAL message
|
||||
def fatal: (message msg) -> IO?
|
||||
|
||||
# Shortcut for logging an ERROR message
|
||||
def error: (message msg) -> IO?
|
||||
|
||||
# Shortcut for logging a WARN message
|
||||
def warn: (message msg) -> IO?
|
||||
|
||||
# Shortcut for logging an INFO message
|
||||
def info: (message msg) -> IO?
|
||||
|
||||
# Shortcut for logging a DEBUG message
|
||||
def debug: (message msg) -> IO?
|
||||
|
||||
# Will the logger output FATAL messages?
|
||||
def fatal?: () -> bool
|
||||
|
||||
# Will the logger output ERROR messages?
|
||||
def error?: () -> bool
|
||||
|
||||
# Will the logger output WARN messages?
|
||||
def warn?: () -> bool
|
||||
|
||||
# Will the logger output INFO messages?
|
||||
def info?: () -> bool
|
||||
|
||||
# Will the logger output DEBUG messages?
|
||||
def debug?: () -> bool
|
||||
|
||||
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.
|
||||
def format: (message arg) -> String
|
||||
end
|
||||
|
||||
class Log < BasicLog
|
||||
# Format of the timestamp which is applied to each logged line. The
|
||||
# default is <tt>"[%Y-%m-%d %H:%M:%S]"</tt>
|
||||
attr_accessor time_format: String
|
||||
|
||||
#
|
||||
# Same as BasicLog#initialize
|
||||
#
|
||||
# You can set the timestamp format through #time_format
|
||||
def initialize: (?BasicLog::log_file log_file, ?Integer? level) -> void
|
||||
|
||||
#
|
||||
# Same as BasicLog#log
|
||||
def log: (Integer level, String data) -> IO?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user