Skip to content

Commit

Permalink
feat(docs): add developer log
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Oct 20, 2024
1 parent 1552bf5 commit 8b3f183
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
16 changes: 16 additions & 0 deletions docs/guide/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ cp conf/live777.toml live777.toml
cp conf/liveman.toml liveman.toml
```

## Log

Use `RUST_LOG` environment variable for set custom log level

For `live777`, default log set

```bash
RUST_LOG=live777=<cfg.log.level>,net4mqtt=<cfg.log.level>,http_log=<cfg.log.level>,webrtc=error",
```
You can use this for override default log set
```bash
RUST_LOG=live777=error,net4mqtt=debug,webrtc=error",
```

## Run in debug mode

### WebUI
Expand Down
16 changes: 16 additions & 0 deletions docs/zh/guide/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ cp conf/live777.toml live777.toml
cp conf/liveman.toml liveman.toml
```

## Log

可以使用 `RUST_LOG` 环境变量来设置日志分模块输出

比如 `live777`, 目前模块日志输出为:

```bash
RUST_LOG=live777=<cfg.log.level>,net4mqtt=<cfg.log.level>,http_log=<cfg.log.level>,webrtc=error",
```
我们可以用这个变量覆盖默认的日志输出方案
```bash
RUST_LOG=live777=error,net4mqtt=debug,webrtc=error",
```

## 以开发模式运行

### WebUI
Expand Down
2 changes: 1 addition & 1 deletion src/liveman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() {

#[cfg(debug_assertions)]
log::set(format!(
"liveman={},liveion={},http_log={},webrtc=error",
"liveman={},net4mqtt={},http_log={},webrtc=error",
cfg.log.level, cfg.log.level, cfg.log.level
));

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ async fn main() {
let cfg: liveion::config::Config = utils::load("live777".to_string(), args.config);
cfg.validate().unwrap();
log::set(format!(
"live777={},liveion={},http_log={},webrtc=error",
cfg.log.level, cfg.log.level, cfg.log.level
"live777={},liveion={},net4mqtt={},http_log={},webrtc=error",
cfg.log.level, cfg.log.level, cfg.log.level, cfg.log.level
));
warn!("set log level : {}", cfg.log.level);
debug!("config : {:?}", cfg);
Expand Down

0 comments on commit 8b3f183

Please sign in to comment.