custom_logging

Description

Implements a custom logging service. The logging setup is based upon the standard Python logging library and offers some advantages:

  • Standard logging across multiple apps using this module.

  • Ease of use and configuration, with only necessary options.

  • Extra functionality:

    • E-mail notification over TLS.

    • Coloured output to a terminal

    • Improved file rotation naming.

    • Logging over TCP socket compatible with the socket_comm module.

lab_utils.custom_logging.SUCCESS

New log level (25) intended to report successful events to Slack, between INFO (20) and WARNING (30).

Type

int

Classes

ColoredFormatter

Console formatter that prepends the coloured severity level of the message.

CustomLogger

Custom logging class based on the default Python Logger.

CustomTimedRotatingFileHandler

Variation of TimedRotatingFileHandler.

NonPickledSocketHandler

Socket handler that sends non-pickled strings.

TlsSMTPHandler

SMTPHandler with TLS support.

Functions

configure_logging

Sets up the custom logger.

getLogger

Overrides the Python standard logging.getLogger() to fix type completion hints, referring them to CustomLogger instead of Logger.

string_to_bool

Parses a variety of strings (e.g.