Cli Logger Class#

class expectmine.logger.loggers.cli_logger.CliLogger(log_level: LogLevel, write_logfile: bool, path: Path | None)[source]#

Bases: BaseLogger

Cli logger which prints messages and optionally logs them to a file.

__init__(log_level: LogLevel, write_logfile: bool, path: Path | None)[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.

debug(message: str | Exception)[source]#

Writes debug info to the log.

Parameters:

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

Raises:

TypeError – If the arguments have the wrong type.

error(message: str | Exception)[source]#

Writes an error to the log.

Parameters:

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

Raises:

TypeError – If the arguments have the wrong type.

info(message: str | Exception)[source]#

Writes info to the log.

Parameters:

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

Raises:

TypeError – If the arguments have the wrong type.

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

Writes a message to the log.

Parameters:

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

Raises:

TypeError – If the arguments have the wrong type.

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

Writes a warning to the log.

Parameters:

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

Raises:

TypeError – If the arguments have the wrong type.