mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.1 KiB
94 lines
2.1 KiB
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
|