#debug #dev #development


A debug crate for rust inspired by NodeJS debug module, colored, including crate name, file name and line, filtered by glob patterns

4 releases

Uses old Rust 2015

0.1.3 Aug 9, 2017
0.1.2 Aug 8, 2017
0.1.1 Aug 8, 2017
0.1.0 Aug 8, 2017

#10 in #dev

MIT license

81 lines

debug-rs   Build Status Latest Version docs License

A debug crate for rust inspired by NodeJS debug module.


  • colored
  • including crate name, file name and line
  • filtered by glob patterns.


debug-rs = "*"

or using cargo-edit

cargo add debug-rs


Here is the code in examples folder:

extern crate debug_rs;

fn main() {
    debug!(666, 33, "aaa");

    debug!(vec![1, 2, 3]);

Then run with environment variable DEBUG=debug (because the examples' package name is still debug):

If environment variable DEBUG is undefined, then it won't print anything.


Running with env variables in windows shell might be a little different:

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 <package name>:<file name>: 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

<package name>:<file name>:L<line number> ...custom variables


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:

debug-rs = { version = "*", default-features=false }

Controlled by features:

debug-rs = { version = "*", default-features=false, features=["disable"] }




~76K SLoC