catch_logs class

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

class brian2.utils.logger.catch_logs(log_level=30, only_from=('brian2',))[source]

Bases: object

A context manager for catching log messages. Use this for testing the messages that are logged. Defaults to catching warning/error messages and this is probably the only real use case for testing. Note that while this context manager is active, all log messages are suppressed. Using this context manager returns a list of (log level, name, message) tuples.