fparser.common.tests.logging_utils
Helps with testing methods which write to the standard logger.
Module Contents
Classes
Records logged output for later examination. |
- class fparser.common.tests.logging_utils.CaptureLoggingHandler(*args, **kwargs)[source]
Bases:
logging.Handler
Records logged output for later examination.
This is a standard handler for the built-in Python logging system. To make use of it simply register an instance with the logger using a command such as “logging.getLogger(__class__).addHandler( CaptureLoggingHandler() )”
Any log message raised while this handler is in use will be recorded to a memory buffer for later use. This object has attributes ‘debug’, ‘info’, ‘warning’, ‘error’ and ‘critical’, each of which is a list of logged messages. Only the message text is recorded, everything else is lost.
- emit(record)[source]
Handles a logged event. The event is passed from the logging system and recorded for future inspection.
:param
logging.LogRecord
record The event being logged.