LsstLogAdapter#

class lsst.utils.logging.LsstLogAdapter(logger, extra=None, merge_extra=False)#

Bases: LoggerAdapter

A special logging adapter to provide log features for LSST code.

Expected to be instantiated initially by a call to getLogger().

This class provides enhancements over logging.Logger that include:

  • Methods for issuing trace and verbose level log messages.

  • Provision of a context manager to temporarily change the log level.

  • Attachment of logging level constants to the class to make it easier for a Task writer to access a specific log level without having to know the underlying logger class.

Attributes Summary

CRITICAL

DEBUG

ERROR

FATAL

INFO

TRACE

VERBOSE

WARN

WARNING

handlers

Log handlers associated with this logger.

level

Return current level of this logger (int).

Methods Summary

addHandler(handler)

Add a handler to this logger.

fatal(msg, *args, **kwargs)

getChild(name)

Get the named child logger.

removeHandler(handler)

Remove the given handler from the underlying logger.

setLevel(level)

Set the level for the logger, trapping lsst.log values.

temporary_log_level(level)

Temporarily set the level of this logger.

trace(fmt, *args, **kwargs)

Issue a TRACE level log message.

verbose(fmt, *args, **kwargs)

Issue a VERBOSE level log message.

Attributes Documentation

CRITICAL = 50#
DEBUG = 10#
ERROR = 40#
FATAL = 50#
INFO = 20#
TRACE = 5#
VERBOSE = 15#
WARN = 30#
WARNING = 30#
handlers#

Log handlers associated with this logger.

level#

Return current level of this logger (int).

Methods Documentation

addHandler(handler: Handler) None#

Add a handler to this logger.

Parameters#

handlerlogging.Handler

Handler to add. The handler is forwarded to the underlying logger.

fatal(msg: str, *args: Any, **kwargs: Any) None#
getChild(name: str) LsstLogAdapter#

Get the named child logger.

Parameters#

namestr

Name of the child relative to this logger.

Returns#

childLsstLogAdapter

The child logger.

removeHandler(handler: Handler) None#

Remove the given handler from the underlying logger.

Parameters#

handlerlogging.Handler

Handler to remove.

setLevel(level: int | str) None#

Set the level for the logger, trapping lsst.log values.

Parameters#

levelint

The level to use. If the level looks too big to be a Python logging level it is assumed to be a lsst.log level.

temporary_log_level(level: int | str) Generator#

Temporarily set the level of this logger.

Parameters#

levelint

The new temporary log level.

trace(fmt: str, *args: Any, **kwargs: Any) None#

Issue a TRACE level log message.

Arguments are as for logging.info. TRACE is lower than DEBUG.

Parameters#

fmtstr

Log message.

*argsAny

Parameters references by log message.

**kwargsAny

Parameters forwarded to log.

verbose(fmt: str, *args: Any, **kwargs: Any) None#

Issue a VERBOSE level log message.

Arguments are as for logging.info. VERBOSE is between DEBUG and INFO.

Parameters#

fmtstr

Log message.

*argsAny

Parameters references by log message.

**kwargsAny

Parameters forwarded to log.