LogCapture class

(Shortest import: from brian2.utils.logger import LogCapture)

class brian2.utils.logger.LogCapture(log_list, log_level=30)[source]

Bases: logging.Handler

A class for capturing log warnings. This class is used by catch_logs to allow testing in a similar way as with warnings.catch_warnings.

Methods

emit(record) Do whatever it takes to actually log the specified logging record.
install() Install this handler to catch all warnings.
uninstall() Uninstall this handler and re-connect the previously installed handlers.

Details

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

install()[source]

Install this handler to catch all warnings. Temporarily disconnect all other handlers.

uninstall()[source]

Uninstall this handler and re-connect the previously installed handlers.