gfw.common.logging#

Logging utilities.

Classes

LoggerConfig

Helper class to setup the root logger.

class LoggerConfig(format_='%(asctime)s - %(name)s - %(message)s', warning_level=(), error_level=())[source]#

Helper class to setup the root logger.

Parameters:
  • format – Logger format.

  • warning_level (tuple[str, ...]) – List of packages/modules for which to set the log level as WARNING.

  • error_level (tuple[str, ...]) – List of packages/modules for which to set the log level as ERROR.

setup(verbose=False, rich=True, log_file=None, log_stream=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)[source]#

Initializes and configures the root logger.

Parameters:
  • verbose (bool) – If true, turns logger level to DEBUG.

  • rich (bool) – Whether to use Rich library to colorize console output.

  • log_file (str | Path | None) – Path to file in which to save logs.

  • log_stream (TextIO) – Destination stream for log output. Defaults to sys.stderr. Typically set to sys.stdout or sys.stderr, but can be any text-mode file-like object (e.g. an open file or io.StringIO) that implements a write(str) method. Ignored if rich=True, since RichHandler manages its own output stream.

Return type:

Logger