#debug-mode #log-debug #log

debug-log

dbg! and eprintln! that only run on debug mode. WASM is supported.

10 releases

0.3.1 Jan 5, 2024
0.3.0 Jan 3, 2024
0.2.2 Nov 4, 2023
0.2.1 Jun 29, 2023
0.1.4 Nov 28, 2022

#156 in WebAssembly

Download history 2/week @ 2023-12-19 18/week @ 2023-12-26 24/week @ 2024-01-02 7/week @ 2024-01-09 27/week @ 2024-02-13 69/week @ 2024-02-20 41/week @ 2024-02-27 8/week @ 2024-03-05 24/week @ 2024-03-12 9/week @ 2024-03-19 7/week @ 2024-03-26 43/week @ 2024-04-02

84 downloads per month
Used in crdt-richtext

MIT license

13KB
218 lines

debug-log

Documentation

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 API

The output log is super easy to read on VS Code with sticky scroll enabled.

Example

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

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
    }
}

Dependencies

~26–270KB