logging.file module

Functions that configure pwfdf-api file logging streams.

Function

Description

verbose

Configures a file log stream at the DEBUG level

info

Configures a file log stream at the INFO level

quiet

Configures a file log at the WARNING level


pwfdf_api.logging.file.verbose(path, format='%(asctime)s - %(name)s - %(message)s', *, rotate_bytes=None, backup_count=1, **handler_kwargs)

Adds a FileHandler at the DEBUG level

File Log
verbose(path)
verbose(path, format)

Adds a FileHandler to the pwfdf-api’s base logger at the DEBUG level, and ensures the pwfdf-api base logger passes messages at this level. The path input is the path to the file that will hold the log.

By default, sets the log format to include the timestamp, logger name, and logging message. Use format to specify a logging format for the FileHandler instead. Here, format may either be a logging format string, or a logging.Formatter object. Alternatively, set format=None to inherit the format of any pre-existing FileHandlers that target the same log file.

Rotating Log
verbose(..., *, rotate_bytes)
verbose(..., *, rotate_bytes, backup_count)

Options for rotating the file log based on size. Use rotate_bytes to rotate the log file after reaching a maximum allowed number of bytes. Use backup_count to set the number of backup log files that should be saved (defaults to 1).

FileHandler Options
verbose(..., **handler_kwargs)

Specifies additional options for the FileHandler or RotatingFileHandler constructor.

Inputs:
  • path (str | Path) – The path to the log file

  • format (str | logging.Formatter | None) – An optional logging format string or logging.Formatter object

  • rotate_bytes (int, optional) – The maximum allowed number of bytes when rotating the log file base on size

  • backup_count (int) – The number of backup log files to save when rotating

  • handler_kwargs (Any) – Additional options for the handler constructor

Outputs:

FileHandler – The new pwfdf-api FileHandler

pwfdf_api.logging.file.info(path, format='%(asctime)s - %(name)s - %(message)s', *, rotate_bytes=None, backup_count=1, **handler_kwargs)

Adds a FileHandler at the INFO level

File Log
info(path)
info(path, format)

Adds a FileHandler to the pwfdf-api’s base logger at the INFO level, and ensures the pwfdf-api base logger passes messages at this level. The path input is the path to the file that will hold the log.

By default, sets the log format to include the timestamp, logger name, and logging message. Use format to specify a logging format for the FileHandler instead. Here, format may either be a logging format string, or a logging.Formatter object. Alternatively, set format=None to inherit the format of any pre-existing FileHandlers that target the same log file.

Rotating Log
info(..., *, rotate_bytes)
info(..., *, rotate_bytes, backup_count)

Options for rotating the file log based on size. Use rotate_bytes to rotate the log file after reaching a maximum allowed number of bytes. Use backup_count to set the number of backup log files that should be saved (defaults to 1).

FileHandler Options
info(..., **handler_kwargs)

Specifies additional options for the FileHandler or RotatingFileHandler constructor.

Inputs:
  • path (str | Path) – The path to the log file

  • format (str | logging.Formatter | None) – An optional logging format string or logging.Formatter object

  • rotate_bytes (int, optional) – The maximum allowed number of bytes when rotating the log file base on size

  • backup_count (int) – The number of backup log files to save when rotating

  • handler_kwargs (Any) – Additional options for the handler constructor

Outputs:

FileHandler – The new pwfdf-api FileHandler

pwfdf_api.logging.file.quiet(path, format='%(asctime)s - %(name)s - %(message)s', *, rotate_bytes=None, backup_count=1, **handler_kwargs)

Adds a FileHandler at the WARNING level

File Log
quiet(path)
quiet(path, format)

Adds a FileHandler to the pwfdf-api’s base logger at the WARNING level, and ensures the pwfdf-api base logger passes messages at this level. The path input is the path to the file that will hold the log.

By default, sets the log format to include the timestamp, logger name, and logging message. Use format to specify a logging format for the FileHandler instead. Here, format may either be a logging format string, or a logging.Formatter object. Alternatively, set format=None to inherit the format of any pre-existing FileHandlers that target the same log file.

Rotating Log
quiet(..., *, rotate_bytes)
quiet(..., *, rotate_bytes, backup_count)

Options for rotating the file log based on size. Use rotate_bytes to rotate the log file after reaching a maximum allowed number of bytes. Use backup_count to set the number of backup log files that should be saved (defaults to 1).

FileHandler Options
quiet(..., **handler_kwargs)

Specifies additional options for the FileHandler or RotatingFileHandler constructor.

Inputs:
  • path (str | Path) – The path to the log file

  • format (str | logging.Formatter | None) – An optional logging format string or logging.Formatter object

  • rotate_bytes (int, optional) – The maximum allowed number of bytes when rotating the log file base on size

  • backup_count (int) – The number of backup log files to save when rotating

  • handler_kwargs (Any) – Additional options for the handler constructor

Outputs:

FileHandler – The new pwfdf-api FileHandler