Skip to content

Commit

Permalink
Support change LOG level
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper committed Aug 29, 2023
1 parent 0e53bc5 commit d61bfd1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ sudo duectl start
{'DBCollector': {'OpenTracer': {'count': 31, 'first at': 249920233249912, 'last': Tracking(tracer='OpenTracer', pid=641616, uid=1000, gid=1000, comm='node', cwd=None, fname='SOME-FILE', timestamp=249923762308577, extended={})}}}
```

启动 `DEBUG`日志

```bash
sudo DUETECTOR_LOG_LEVEL=DEBUG duectl start
```

启动时,配置文件将自动生成,对应路径为 `~/.config/duetector` ,可以使用 `--config`指定使用的配置文件

```bash
Expand Down
8 changes: 7 additions & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ Press `CRTL+C` to exit monitoring and you will see a summary output on the scree
{'DBCollector': {'OpenTracer': {'count': 31, 'first at': 249920233249912, 'last': Tracking(tracer='OpenTracer', pid=641616, uid=1000, gid= 1000, comm='node', cwd=None, fname='SOME-FILE', timestamp=249923762308577, extended={})}}}
```

Enable `DEBUG` log

```bash
sudo DUETECTOR_LOG_LEVEL=DEBUG duectl start
```

At startup, the configuration file will be automatically generated at `~/.config/duetector`, and you can specify the configuration file to use with `--config`.

```bash
sudo duectl start --config <config-file-path
sudo duectl start --config <config-file-path>
```

When using a plugin, the default configuration file will not contain the plugin's configuration, use the dynamically-generated configuration directive to generate a configuration file with the plugin's configuration, this directive also supports merging existing configuration files and environment variables.
Expand Down
6 changes: 6 additions & 0 deletions duetector/log.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
import os

USER_DEFINED_LOG_LEVEL = os.getenv("DUETECTOR_LOG_LEVEL", "INFO")

os.environ["LOGURU_LEVEL"] = USER_DEFINED_LOG_LEVEL

from loguru import logger

0 comments on commit d61bfd1

Please sign in to comment.