MovementLogger#
- class movement.utils.logging.MovementLogger[source]#
Bases:
objectA custom logger extending the
loguru logger.Methods
configure([log_file_name, log_directory, ...])Configure a rotating file logger and optionally a console logger.
error(message, *args, **kwargs)Log error message and optionally return an Exception.
exception(message, *args, **kwargs)Log error message with traceback and optionally return an Exception.
- configure(log_file_name='movement', log_directory=PosixPath('/home/runner/.movement'), console=True)[source]#
Configure a rotating file logger and optionally a console logger.
This method configures a rotating log file that logs at the DEBUG level with a maximum size of 5 MB and retains the last log file. It also optionally adds a console (
sys.stderr) handler that logs at the WARNING level. Finally, it redirects warnings from thewarningsmodule to the logger.- Parameters:
log_file_name (str, optional) – The name of the log file. Defaults to
"movement".log_directory (pathlib.Path, optional) – The directory to store the log file in. Defaults to
"~/.movement". A different directory can be specified, for example, for testing purposes.console (bool, optional) – Whether to add a console logger. Defaults to
True.
- error(message, *args, **kwargs)[source]#
Log error message and optionally return an Exception.
This method overrides loguru’s
logger.error()to optionally return an Exception if the message is an Exception.
- exception(message, *args, **kwargs)[source]#
Log error message with traceback and optionally return an Exception.
This method overrides loguru’s
logger.exception()to optionally return an Exception if the message is an Exception.