Logging module¶
- class ulogging.FileHandler(file: str)[source]¶
Bases:
ulogging.Handler
A handler used to performs files operations.
- file¶
the file path
- formatter¶
Sets a format for logs default format is “{level}: {name} (+{time}s) -> {message}”
- class ulogging.Handler[source]¶
Bases:
object
A class that gives general methods of a handler used for I/O operations.
- property level: int¶
- class ulogging.Logger(name: str)[source]¶
Bases:
object
A class to perform filtering log messages before sending to handlers.
Conventionnal usage: logger = logging.Logger(__name__)
- name¶
The logger’s name
- propagate¶
If set to True (default), logs will be written in root’s handlers.
- LOGGERS = {'motors': Logger(name=motors, level=1), 'robot': Logger(name=robot, level=1), 'root': Logger(name=root, level=1), 'sensors': Logger(name=sensors, level=1)}¶
- add_handler(handler: ulogging.Handler) None [source]¶
Add an Handler instance to the logger.
- Parameters
handler – A Handler class (FileHandler or StreamHandler)
- property handlers: list¶
Returns a list of handlers that are accessible by the logger.
If propagate was set to True, data were sent to root’s handlers.
- Returns
A list of all handlers.
- log(level: str, message: str) None [source]¶
Write a log line in a file.
Tests if the log’s request level is superior to the logger level, then format the string with the format of the handler and write it. Shortcuts methods are debug(), info(), error(), warning() and critical().
- Parameters
level – Can be DEBUG, INFO, WARNING, ERROR or CRITICAL, or a int from 0 to 4.
message – The message to write.
- class ulogging.StreamHandler[source]¶
Bases:
ulogging.Handler
A handler used to write logs in the output console
- formatter¶
Sets a format for logs default format is “{level}: {name} -> {message}”