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:

BaseLogger

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.

abstract log(message: str | Exception) None[source]#

Writes a message to the log.

Parameters:

message (str | Exception) – Message to be logged.

Raises:

TypeError – If the arguments have the wrong type.

abstract warn(message: str | Exception) None[source]#

Writes a warning 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: Enum

LogLevels 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'#