https://github.com/zaaack/debug-rs
A debug crate for rust inspired by nodejs debug module.
https://github.com/zaaack/debug-rs
color debug rust
Last synced: 3 months ago
JSON representation
A debug crate for rust inspired by nodejs debug module.
- Host: GitHub
- URL: https://github.com/zaaack/debug-rs
- Owner: zaaack
- License: mit
- Created: 2017-08-08T01:45:07.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-14T00:15:38.000Z (over 5 years ago)
- Last Synced: 2025-03-28T18:52:36.655Z (about 1 year ago)
- Topics: color, debug, rust
- Language: Rust
- Homepage:
- Size: 64.5 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# debug-rs [![Build Status]][travis] [![Latest Version]][crates.io] [![docs]][docs.rs] [![License]][License Link]
[Build Status]: https://api.travis-ci.org/zaaack/debug-rs.svg?branch=master
[travis]: https://travis-ci.org/zaaack/debug-rs
[Latest Version]: https://img.shields.io/crates/v/debug-rs.svg
[crates.io]: https://crates.io/crates/debug-rs
[docs]: https://docs.rs/debug-rs/badge.svg
[docs.rs]: https://docs.rs/debug-rs/
[License]: https://img.shields.io/badge/license-MIT-blue.svg
[License Link]: https://github.com/zaaack/debug-rs/blob/master/LICENSE
A debug crate for rust inspired by NodeJS [debug](https://github.com/visionmedia/debug) module.
## Features
* colored
* including crate name, file name and line
* filtered by glob patterns.
## Install
```toml
debug-rs = "*"
```
or using cargo-edit
```sh
cargo add debug-rs
```
## Usage
Here is the code in examples folder:
```rust
#[macro_use]
extern crate debug_rs;
fn main() {
debug!(666, 33, "aaa");
debug!(vec![1, 2, 3]);
debugf!("num: {}, str: {},", 8, "129");
debugf!("num: {:?}, str: {:?},", 129, "8");
}
```
Then run with environment variable `DEBUG=debug:examples*` (because the examples' package name is still `debug`):

If environment variable `DEBUG` is undefined, then it won't print anything.
## Windows
Running with env variables in windows shell might be a little different:
```sh
DEBUG=*,-not_this cargo run # for *unix
# or
set DEBUG=*,-not_this; cargo run # for windows
# or
$env:DEBUG = "*,-not_this"; cargo run # for PowerShell
```
## DEBUG format
1. Single glob pattern for `:`: e.g. `DEBUG=debug*`
2. Multi glob patterns separated by comma: e.g. `DEBUG=debug:examples*,hyper*,`
3. Exclude global patterns by prefix "-": e.g. `DEBUG=*,-not_this*`
## Output format
```
::L ...custom variables
```
## Performance
`debug_build_only` feature can make debug macro won't generate any code in release mode, and default is turn on. you can disable it by config features in Cargo.toml.
Working in release mode:
```toml
[dependencies]
debug-rs = { version = "*", default-features=false }
```
Controlled by features:
```toml
[dependencies]
debug-rs = { version = "*", default-features=false, features=["disable"] }
```
## License
MIT