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.
-
flexx.set_log_level(level, match=None)¶ 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
that contain
matchas a substring (and has the appropriatelevel) will be displayed. Match can also be a compiled regexp.
Notes
If level is DEBUG, the method emitting the log message will be prepended to each log message. Note that if
levelis DEBUG or if thematchoption is used, a small overhead is added to each logged message.
-
class
flexx.util.logging.capture_log(level, match=None)¶ 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)