1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Updated docs containing info about trace-if

This commit is contained in:
A_D 2021-08-12 16:46:26 +02:00
parent 03d90daedc
commit 80fbfd1780
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4

View File

@ -409,20 +409,27 @@ In addition to that we utilise one of the user-defined levels as:
selected from Settings in the UI.
As well as just using bare `logger.trace(...)` you can also gate it to only
log if asked to at invocation time by utilising the `--trace-on ...`
log if asked to at invocation time by utilising the `--trace-on ...`
command-line argument. e.g.
`EDMarketConnector.py --trace --trace-on edsm-cmdr-events`. Note how you
still need to include `--trace`. The code to check and log would be like:
still need to include `--trace`.
`--trace-on` stores its arguments in `config.trace_on`.
To make use of `--trace-on`, you can either check `config.trace_on` yourself:
```python
import config
if 'my-trace-rule' in config.trace_on:
logger.trace('my log message')
```
or you can use the helper method provided on `logger`:
```python
import config as conf_module # Necessary to see the same config.trace_on as elsewhere
logger.trace_if('my-trace-rule', 'my-log-message')
```
if 'edsm-cmdr-events' in conf_module.trace_on:
logger.trace(f'De-queued ({cmdr=}, {entry["event"]=})')
```
This way you can set up TRACE logging that won't spam just because of
`--trace` being used.
This way you can set up TRACE logging that won't spam just because `--trace` is used.
---