PeriodicLogger

class lsst.utils.logging.PeriodicLogger(logger: Logger | LsstLogAdapter, interval: float | None = None, level: int = 15)

Bases: object

Issue log messages if a time threshold has elapsed.

This class can be used in long-running sections of code where it would be useful to issue a log message periodically to show that the algorithm is progressing.

The first time threshold is counted from object construction, so in general the first call to log does not log.

Parameters:
loggerlogging.Logger or LsstLogAdapter

Logger to use when issuing a message.

intervalfloat

The minimum interval in seconds between log messages. If None, LOGGING_INTERVAL will be used.

levelint, optional

Log level to use when issuing messages, default is VERBOSE.

Attributes Summary

LOGGING_INTERVAL

Default interval between log messages in seconds.

Methods Summary

log(msg, *args)

Issue a log message if the interval has elapsed.

Attributes Documentation

LOGGING_INTERVAL = 600.0

Default interval between log messages in seconds.

Methods Documentation

log(msg: str, *args: Any) bool

Issue a log message if the interval has elapsed.

The interval is measured from the previous call to log, or from the creation of this object.

Parameters:
msgstr

Message to issue if the time has been exceeded.

*argsAny

Arguments to be merged into the message string, as described under logging.Logger.debug.

Returns:
issuedbool

Returns True if a log message was sent to the logging system. Returns False if the interval has not yet elapsed. Returning True does not indicate whether the log message was in fact issued by the logging system.