PeriodicLogger

class lsst.utils.logging.PeriodicLogger(logger: Union[Logger, LsstLogAdapter], interval: Optional[float] = 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.

Parameters:
loggerlogging.Logger or LsstLogAdapter

Logger to use when issuing a message.

intervalfloat

The minimum interval between log messages. If None the class default will be used.

levelint, optional

Log level to use when issuing messages.

Attributes Summary

LOGGING_INTERVAL

Default interval between log messages.

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.

Methods Documentation

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

Issue a log message if the interval has elapsed.

Parameters:
msgstr

Message to issue if the time has been exceeded.

*argsAny

Parameters to be passed to the log system.

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.