Skip to content

Commit 506f57a

Browse files
committed
feat(crypto-nodejs): Enable traace filtering and change the env var to MATRIX_LOG.
1 parent 1b2c644 commit 506f57a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

crates/matrix-sdk-crypto-nodejs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ napi = { git = "https://github.com/Hywan/napi-rs", branch = "feat-either-n-up-to
3333
napi-derive = { git = "https://github.com/Hywan/napi-rs", branch = "feat-either-n-up-to-26" }
3434
serde_json = "1.0.79"
3535
http = "0.2.6"
36-
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "time", "smallvec", "fmt"], optional = true }
36+
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "time", "smallvec", "fmt", "env-filter"], optional = true }
3737

3838
[build-dependencies]
39-
napi-build = "2.0.0"
39+
napi-build = "2.0.0"

crates/matrix-sdk-crypto-nodejs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ turned on:
100100
$ npm run build -- --features tracing
101101
```
102102

103-
Now, you can use the `RUST_LOG` environment variable to tweak the log filtering, such as:
103+
Now, you can use the `MATRIX_LOG` environment variable to tweak the log filtering, such as:
104104

105105
```sh
106-
$ RUST_LOG=debug npm run test
106+
$ MATRIX_LOG=debug npm run test
107107
```
108108

109109
See
110110
[`tracing-subscriber`](https://tracing.rs/tracing_subscriber/index.html)
111-
to learn more about the `RUST_LOG` environment variable.
111+
to learn more about the `RUST_LOG`/`MATRIX_LOG` environment variable.
112112

113113
## Documentation
114114

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use napi_derive::*;
2+
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
23

34
/// Subscribe to tracing events, i.e. turn on logs.
45
#[napi]
56
pub fn init_tracing() {
6-
tracing_subscriber::fmt::init();
7+
tracing_subscriber::registry()
8+
.with(fmt::layer())
9+
.with(EnvFilter::from_env("MATRIX_LOG"))
10+
.init();
711
}

0 commit comments

Comments
 (0)