Logging
Logging setup with colors and redaction of secrets.
- class hw_tests.logging.RedactingFormatter(formatter)
Formatter that redacts the output of another formatter.
See
redact_text()for what is redacted.- Parameters:
formatter – Formatter to wrap.
- format(record)
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- class hw_tests.logging.ColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)
Formatter that colors the level name by severity.
- format(record)
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- hw_tests.logging.register_sensitive(value)
Register a runtime value for redaction from subsequent log output.
- hw_tests.logging.install_log_redaction(handlers)
Wrap handlers with the redacting formatter, without double wrapping.