src.system.logger.Logger

class src.system.logger.Logger

Singleton logger class. Writes messages to disk and prints messages to console.

Inheritance Diagram

Inheritance diagram of Logger

Variables & Properties

instance

Global singleton instance.

lock

Lock object to prevent race conditions when writing to the log file.

log_file

Log file object; console output is piped here.

timestamp

Returns a timestamp as-of now.

Methods

__init__()

print(message[, level])

Prints a message to both console and log file.

raise_expr(expr)

Logs an exception in both the console and log file, then raises the exception.

Details

__init__()
instance: ClassVar[Self] = None

Global singleton instance.

lock: ClassVar[Lock] = <Lock(owner=None)>

Lock object to prevent race conditions when writing to the log file.

log_file: ClassVar[TextIO] = None

Log file object; console output is piped here.

print(message: str, level: LoggerLevel = LoggerLevel.MESSAGE) None

Prints a message to both console and log file.

Parameters:
  • message – Message to print.

  • level – Logging level and severity.

Returns:

Nothing.

raise_expr(expr: Exception) NoReturn

Logs an exception in both the console and log file, then raises the exception.

Parameters:

expr – Exception to raise and log.

Returns:

Never.

property timestamp: str

Returns a timestamp as-of now.

Returns:

Returns a timestamp as a string.