apache_beam.utils.logger module

Helper functions for easier logging.

This module provides a few convenient logging methods, some of which were adopted from https://github.com/abseil/abseil-py/blob/master/absl/logging/__init__.py in https://github.com/facebookresearch/detectron2/blob/main/detectron2/utils/logger.py

apache_beam.utils.logger.log_first_n(lvl: int, msg: str, *args, n: int = 1, name: str | None = None, key: str | tuple[str] = 'caller') None[source]

Log only for the first n times.

Parameters:
  • lvl (int) – the logging level

  • msg (str)

  • n (int)

  • name (str) – name of the logger to use. Will use the caller’s module by default.

  • key (str or tuple[str]) – the string(s) can be one of “caller” or “message”, which defines how to identify duplicated logs. For example, if called with n=1, key=”caller”, this function will only log the first call from the same caller, regardless of the message content. If called with n=1, key=”message”, this function will log the same content only once, even if they are called from different places. If called with n=1, key=(“caller”, “message”), this function will not log only if the same caller has logged the same message before.

apache_beam.utils.logger.log_every_n(lvl: int, msg: str, *args, n: int = 1, name: str | None = None) None[source]

Log once per n times.

Parameters:
  • lvl (int) – the logging level

  • msg (str)

  • n (int)

  • name (str) – name of the logger to use. Will use the caller’s module by default.

apache_beam.utils.logger.log_every_n_seconds(lvl: int, msg: str, *args, n: int = 1, name: str | None = None) None[source]

Log no more than once per n seconds.

Parameters:
  • lvl (int) – the logging level

  • msg (str)

  • n (int)

  • name (str) – name of the logger to use. Will use the caller’s module by default.