Logger Base Class#
Warning
This class is an abstract implementation using ABC. It serves as an interface for other IO classes to build upon. You should never import BaseIo to use as IO for your pipeline steps.
- class expectmine.logger.base_logger.BaseLogger(log_level: LogLevel, write_logfile: bool, path: Path | None, **kwargs: Dict[Any, Any])[source]#
Bases:
ABC- abstract __init__(log_level: LogLevel, write_logfile: bool, path: Path | None, **kwargs: Dict[Any, Any])[source]#
Produces a scoped instance of type BaseLogger.
- Parameters:
log_level (LogLevel) β The loglevel of the instance
write_logfile (bool) β Boolean indicating weather logs are written to files.
path (Path | None) β Path to the directory where logs are written to.
- Returns:
A scoped logger instance.
- Return type:
- Example:
>>> BaseLogger(LogLevel.ERROR, true, Path('foo')) BaseLogger
>>> BaseLogger(LogLevel.ERROR, true) ValueError("Path can not be empty if write has been set to true.")
- Raises:
TypeError β If the arguments have the wrong type.
ValueError β If path is empty in case write was set to true. Or the path is invalid.
- abstract debug(message: str | Exception) None[source]#
Writes debug info to the log.
- Parameters:
message (str | Exception) β Message to be logged.
- Raises:
TypeError β If the arguments have the wrong type.
- abstract error(message: str | Exception) None[source]#
Writes an error to the log.
- Parameters:
message (str | Exception) β Message to be logged.
- Raises:
TypeError β If the arguments have the wrong type.
- abstract info(message: str | Exception) None[source]#
Writes info to the log.
- Parameters:
message (str | Exception) β Message to be logged.
- Raises:
TypeError β If the arguments have the wrong type.
- class expectmine.logger.base_logger.LogLevel(value)[source]#
Bases:
EnumLogLevels for the logger. The levels include: ALL, DEBUG, INFO, WARN and ERROR. Each logger which implements the BaseLogger also needs to have these 5 log levels.
- ALL = 'NOTSET'#
- DEBUG = 'DEBUG'#
- ERROR = 'ERROR'#
- INFO = 'INFO'#
- WARN = 'WARNING'#