LsstLogAdapter¶
-
class
lsst.utils.logging.
LsstLogAdapter
(logger, extra)¶ Bases:
logging.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
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, str])Set the level for the logger, trapping lsst.log values. temporary_log_level
(level, str])A context manager that temporarily sets 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
¶ Current level of this logger (
int
).
-
manager
¶
-
name
¶
Methods Documentation
-
addHandler
(handler: logging.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, **kwargs) → 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, **kwargs) → 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, **kwargs) → None¶
-
fatalf
(fmt: str, *args, **kwargs) → None¶ Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.
-
getChild
(name: str) → lsst.utils.logging.LsstLogAdapter¶ Get the named child logger.
Parameters: - name :
str
Name of the child relative to this logger.
Returns: - child :
LsstLogAdapter
The child logger.
- name :
-
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, **kwargs) → 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: logging.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: - level :
int
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.
- level :
-
temporary_log_level
(level: Union[int, str]) → Generator[T_co, T_contra, V_co]¶ A context manager that temporarily sets the level of this logger.
Parameters: - level :
int
The new temporary log level.
- level :
-
trace
(fmt: str, *args) → None¶ Issue a TRACE level log message.
Arguments are as for
logging.info
.TRACE
is lower thanDEBUG
.
-
tracef
(fmt: str, *args, **kwargs) → None¶ Deprecated since version v23: Use Python Logger compatible method. Will be removed after v23.
-
verbose
(fmt: str, *args, **kwargs) → None¶ Issue a VERBOSE level log message.
Arguments are as for
logging.info
.VERBOSE
is betweenDEBUG
andINFO
.
-
warn
(msg, *args, **kwargs)¶
-
warnf
(fmt: str, *args, **kwargs) → 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.