bot.log#

Logging.

Module Contents#

Classes#

CustomLogger

Custom implementation of the Logger class with an added trace method.

Functions#

get_logger(→ CustomLogger)

Make mypy recognise that logger is of type CustomLogger.

setup(→ None)

Set up loggers.

setup_sentry(→ None)

Set up the Sentry logging integrations.

_set_trace_loggers(→ None)

Set loggers to the trace level according to the value from the BOT_TRACE_LOGGERS env var.

Attributes#

bot.log.TRACE_LEVEL = 5[source]#
bot.log.LoggerClass[source]#
class bot.log.CustomLogger(name, level=NOTSET)[source]#

Bases: LoggerClass

Custom implementation of the Logger class with an added trace method.

trace(msg: str, *args: list, **kwargs: dict) None[source]#

Log ‘msg % args’ with severity ‘TRACE’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.trace(“Houston, we have an %s”, “interesting problem”, exc_info=1)

bot.log.get_logger(name: str | None = None) CustomLogger[source]#

Make mypy recognise that logger is of type CustomLogger.

bot.log.setup() None[source]#

Set up loggers.

bot.log.setup_sentry() None[source]#

Set up the Sentry logging integrations.

bot.log._set_trace_loggers() None[source]#

Set loggers to the trace level according to the value from the BOT_TRACE_LOGGERS env var.

When the env var is a list of logger names delimited by a comma, each of the listed loggers will be set to the trace level.

If this list is prefixed with a “!”, all of the loggers except the listed ones will be set to the trace level.

Otherwise if the env var begins with a “*”, the root logger is set to the trace level and other contents are ignored.