From 1dc24222ffdb930d4d8f8d580f06f22814f8d20d Mon Sep 17 00:00:00 2001 From: Dave Tapley Date: Wed, 29 Mar 2023 02:20:21 -0700 Subject: [PATCH] Document log groups and console -x (#2161) (#2162) https://github.com/Textualize/textual/discussions/2161 Groups as of: https://github.com/Textualize/textual/blob/ab0de0139c43fe4a8d11ddc5566a22b4ca855e4a/src/textual/_log.py#L4-L15 --- docs/guide/devtools.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/guide/devtools.md b/docs/guide/devtools.md index 087ebf4ce..0f8c87af8 100644 --- a/docs/guide/devtools.md +++ b/docs/guide/devtools.md @@ -72,7 +72,7 @@ textual run --dev my_app.py Anything you `print` from your application will be displayed in the console window. Textual will also write log messages to this window which may be helpful when debugging your application. -### Verbosity +### Increasing verbosity Textual writes log messages to inform you about certain events, such as when the user presses a key or clicks on the terminal. To avoid swamping you with too much information, some events are marked as "verbose" and will be excluded from the logs. If you want to see these log messages, you can add the `-v` switch. @@ -80,6 +80,17 @@ Textual writes log messages to inform you about certain events, such as when the textual console -v ``` +### Decreasing verbosity + +Log messages are classififed in to groups, and the `-x` flag can be used to **exclude** all message from a group. The groups are: `UNDEFINED`, `EVENT`, `DEBUG`, `INFO`, `WARNING`, `ERROR`, `PRINT`, `SYSTEM`, `LOGGING`. The group a message belongs to is printed after its timestamp. + +Multiple groups may be excluded, for example to exclude everything except warning, errors, and `print` statements: + +```bash +textual console -x SYSTEM -x EVENT -x DEBUG -x INFO +``` + + ## Textual log In addition to simple strings, Textual console supports [Rich](https://rich.readthedocs.io/en/latest/) formatting. To write rich logs, import `log` as follows: