Logging¶
Table of Contents
Cross-Process Logging¶
-
class
pavilion.log_setup.
LockFileRotatingFileHandler
(file_name, max_bytes=0, backup_count=0, lock_timeout=10, encoding=None)¶ Bases:
logging.Handler
A logging handler that manages cross-system, cross-process safety by utilizing file based locking. This will also rotate files, as per RotatingFileHandler.
-
__init__
(file_name, max_bytes=0, backup_count=0, lock_timeout=10, encoding=None)¶ Initialize the Locking File Handler. This will attempt to open the file and use the lockfile, just to check permissions.
Parameters: - file_name (Union(str,Path)) – The path to the log file.
- max_bytes (int) – The limit of how much data can go in a single log file before rolling over. Zero denotes no limit.
- backup_count (int) – How many backups (logfile.1, etc) to keep.
- lock_timeout (int) – Wait this long before declaring a lock deadlock, and giving up.
- encoding (str) – The file encoding to use for the log file.
-
_do_rollover
()¶ Roll over our log file. We must have a lock on the file to perform this.
-
_should_rollover
(msg)¶ Check if the message will exceed our rollover limit.
-
emit
(record)¶ Emit the given record, but only after acquiring a lock on the log’s lockfile.
-
handleError
(record: logging.LogRecord) → None¶ Print any logging errors to stderr. We want to know about them.
-
Logger Setup¶
-
pavilion.log_setup.
record_factory
(*fargs, **kwargs)¶ Add the hostname to all logged records.
-
pavilion.log_setup.
setup_loggers
(pav_cfg, verbose=False, err_out=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)¶ Setup the loggers for the Pavilion command. This will include:
- The general log file (as a multi-process/host safe rotating logger).
- The result log file (also as a multi-process/host safe rotating logger).
- The exception log.
Parameters: - pav_cfg – The Pavilion configuration.
- verbose (bool) – When verbose, setup the root logger to print to stderr as well.
- err_out (IO[str]) – Where to log errors meant for the terminal. This exists primarily for testing.