Logging in Flexx¶
Flexx uses the standard Python logging facilities, but adds functionality, most notably the ability to filter messages by a string or regexp.
Set the logging level and match filter
- level (str, int) – The verbosity of messages to print. If a str, it can be either DEBUG, INFO, WARNING, ERROR, or CRITICAL. Note that these are for convenience and are equivalent to passing in logging.DEBUG, etc.
- match (str, regexp, None) – String to match. Only those messages
matchas a substring (and has the appropriate
level) will be displayed. Match can also be a compiled regexp.
If level is DEBUG, the method emitting the log message will be prepended to each log message. Note that if
levelis DEBUG or if the
matchoption is used, a small overhead is added to each logged message.
Context manager to capture log messages. Useful for testing. Usage:
with capture_log(level, match) as log: ... # log is a list strings (as they would have appeared in the console)