PeriodicLogger

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

Parameters:
logger : logging.Logger or LsstLogAdapter

Logger to use when issuing a message.

interval : float

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

level : int, 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) → bool

Issue a log message if the interval has elapsed.

Parameters:
msg : str

Message to issue if the time has been exceeded.

*args : Any

Parameters to be passed to the log system.

Returns:
issued : bool

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.