librelane.logging API

The Logging Module

As the name implies, this handles LibreLane’s logging using the logging module and the rich library.

class librelane.logging.LogLevels(value)

Bases: IntEnum

An enumeration.

class librelane.logging.LevelFilter(levels: Iterable[str], invert: bool = False)

Bases: Filter

Parameters:
  • levels (Iterable[str])

  • invert (bool)

filter(record: LogRecord) bool

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

Parameters:

record (LogRecord)

Return type:

bool

librelane.logging.set_log_level(lv: str | int)

Sets the log level of the default LibreLane logger.

Parameters:

lv (str | int) – Either the name or number of the desired log level.

librelane.logging.reset_log_level()

Sets the log level of the default LibreLane logger back to the default log level.

librelane.logging.get_log_level() int

Obtains the numeric log level of the LibreLane logger.

Return type:

int

librelane.logging.register_additional_handler(handler: Handler)

Adds a new handler to the default LibreLane logger.

Parameters:

handler (Handler) – The new handler. Must be of type logging.Handler or its subclasses.

librelane.logging.deregister_additional_handler(handler: Handler)

Removes a registered handler from the default LibreLane logger.

Parameters:

handler (Handler) – The handler. If not registered, the behavior of this function is undefined.

librelane.logging.verbose(*args, **kwargs)

Logs to the LibreLane logger with the log level VERBOSE.

librelane.logging.debug(*args, **kwargs)

Logs to the LibreLane logger with the log level DEBUG.

Parameters:

msg – The message to log

librelane.logging.info(msg: object, /, **kwargs)

Logs to the LibreLane logger with the log level INFO.

Parameters:

msg (object) – The message to log

librelane.logging.rule(title: str = '', /, **kwargs)

Prints a horizontal line on the terminal enclosing the first argument if the log level is <= INFO.

Kwargs are passed to https://rich.readthedocs.io/en/stable/reference/console.html#rich.console.Console.rule

Parameters:

title (str) – A title string to enclose in the console rule

librelane.logging.success(msg: object, /, **kwargs)

Logs to the LibreLane logger with the log level INFO.

Parameters:

msg (object) – The message to log

librelane.logging.warn(msg: object, /, **kwargs)

Logs to the LibreLane logger with the log level WARNING.

Parameters:

msg (object) – The message to log

librelane.logging.err(msg: object, /, **kwargs)

Logs to the LibreLane logger with the log level ERROR.

Parameters:

msg (object) – The message to log

librelane.logging.subprocess(msg: object, /, **kwargs)

Logs to the LibreLane logger with the log level SUBPROCESS.

Parameters:

msg (object) – The message to log