LsstLogAdapter

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

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).

manager

name

Methods Summary

addHandler(handler)

Add a handler to this logger.

critical(msg, *args, **kwargs)

Delegate a critical call to the underlying logger.

debug(msg, *args, **kwargs)

Delegate a debug call to the underlying logger.

debugf(fmt, *args, **kwargs)

Deprecated since version v23.

error(msg, *args, **kwargs)

Delegate an error call to the underlying logger.

errorf(fmt, *args, **kwargs)

Deprecated since version v23.

exception(msg, *args[, exc_info])

Delegate an exception call to the underlying logger.

fatal(msg, *args, **kwargs)

fatalf(fmt, *args, **kwargs)

Deprecated since version v23.

getChild(name)

Get the named child logger.

getEffectiveLevel()

Get the effective level for the underlying logger.

getLevel()

Deprecated since version v23.

getName()

Deprecated since version v23.

hasHandlers()

See if the underlying logger has any handlers.

info(msg, *args, **kwargs)

Delegate an info call to the underlying logger.

infof(fmt, *args, **kwargs)

Deprecated since version v23.

isDebugEnabled()

Deprecated since version v23.

isEnabledFor(level)

Is this logger enabled for level 'level'?

log(level, msg, *args, **kwargs)

Delegate a log call to the underlying logger, after adding contextual information from this adapter instance.

process(msg, kwargs)

Process the logging message and keyword arguments passed in to a logging call to insert contextual information.

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)

Issue a TRACE level log message.

tracef(fmt, *args, **kwargs)

Deprecated since version v23.

verbose(fmt, *args, **kwargs)

Issue a VERBOSE level log message.

warn(msg, *args, **kwargs)

warnf(fmt, *args, **kwargs)

Deprecated since version v23.

warning(msg, *args, **kwargs)

Delegate a warning call to the underlying logger.

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).

manager
name

Methods Documentation

addHandler(handler: Handler) None

Add a handler to this logger.

The handler is forwarded to the underlying logger.

critical(msg, *args, **kwargs)

Delegate a critical call to the underlying logger.

debug(msg, *args, **kwargs)

Delegate a debug call to the underlying logger.

debugf(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

error(msg, *args, **kwargs)

Delegate an error call to the underlying logger.

errorf(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

exception(msg, *args, exc_info=True, **kwargs)

Delegate an exception call to the underlying logger.

fatal(msg: str, *args: Any, **kwargs: Any) None
fatalf(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

getChild(name: str) LsstLogAdapter

Get the named child logger.

Parameters:
namestr

Name of the child relative to this logger.

Returns:
childLsstLogAdapter

The child logger.

getEffectiveLevel()

Get the effective level for the underlying logger.

getLevel() int

Deprecated since version v23: Use Python Logger compatible .level property. Will be removed after v23.

getName() str

Deprecated since version v23: Use Python Logger compatible ‘name’ attribute. Will be removed after v23.

hasHandlers()

See if the underlying logger has any handlers.

info(msg, *args, **kwargs)

Delegate an info call to the underlying logger.

infof(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

isDebugEnabled() bool

Deprecated since version v23: Use Python Logger compatible isEnabledFor Will be removed after v23.

isEnabledFor(level)

Is this logger enabled for level ‘level’?

log(level, msg, *args, **kwargs)

Delegate a log call to the underlying logger, after adding contextual information from this adapter instance.

process(msg, kwargs)

Process the logging message and keyword arguments passed in to a logging call to insert contextual information. You can either manipulate the message itself, the keyword args or both. Return the message and kwargs modified (or not) to suit your needs.

Normally, you’ll only need to override this one method in a LoggerAdapter subclass for your specific needs.

removeHandler(handler: Handler) None

Remove the given handler from the underlying logger.

setLevel(level: Union[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: Union[int, str]) Generator

Temporarily set the level of this logger.

Parameters:
levelint

The new temporary log level.

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

Issue a TRACE level log message.

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

tracef(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

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.

warn(msg, *args, **kwargs)
warnf(fmt: str, *args: Any, **kwargs: Any) None

Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.

warning(msg, *args, **kwargs)

Delegate a warning call to the underlying logger.