Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zxch3n/debug-log
https://github.com/zxch3n/debug-log
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zxch3n/debug-log
- Owner: zxch3n
- Created: 2022-11-18T15:15:15.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T08:04:00.000Z (10 months ago)
- Last Synced: 2024-10-04T16:22:06.106Z (about 1 month ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple log utils for debugging in Rust.
- 🦀 Enabled only in debug mode when `DEBUG` environment variable is set. You
can change the `DEBUG` value in runtime as well by `set_debug`.
- 🔊 Only log in files whose paths match `DEBUG="filename"`. Match all by using
`DEBUG=""`, or `DEBUG="*"`
- 📦 Group output with `debug_group`
- 📤 WASM support. It will use the console APIThe output log is super easy to read on VS Code with sticky scroll enabled.
# Example
```rust
use debug_log::{debug_dbg, debug_log, group, group_end};
fn main() {
group!("A Group");
{
group!("Sub A Group");
let arr: Vec<_> = (0..3).collect();
debug_dbg!(&arr);
{
group!("Sub Sub A Group");
debug_dbg!(&arr);
group_end!();
}
debug_log!("Hi");
debug_dbg!(&arr);
group_end!();
}{
group!("B Group");
debug_log!("END");
group_end!();
}
group_end!();
}
```Run with `DEBUG=* cargo run`
Output
```log
A Group {
Sub A Group {
[src/lib.rs:144] &arr = [
0,
1,
2,
]
Sub Sub A Group {
[src/lib.rs:147] &arr = [
0,
1,
2,
]
}
[src/lib.rs:150] Hi
[src/lib.rs:151] &arr = [
0,
1,
2,
]
}
B Group {
[src/lib.rs:157] END
}
}
```