4 releases

0.1.9 Oct 16, 2023
0.1.8 Oct 16, 2023
0.1.5 Sep 28, 2023

#264 in Procedural macros

50 downloads per month

MIT license

7KB
90 lines

Define C-like debug trace macro: enter!() and leave!().

Check crate: https://crates.io/crates/dmacro

Thanks to https://stackoverflow.com/questions/38088067.

Example

use dmacro::*;

fn main() {
    enter!();
    println!("Hello, world!");

    trace!();
    trace!("church11");
    trace!("church21", "church22",);
    trace!("church31", "church32", "church33");
    trace!("church31", "church32", "church33", 1024);
    let y = 2023;
    let m = 9;
    let d = 28;
    trace!(format!("{:04}-{:02}-{:02}", y, m, d));
    trace!(format!("{y:04}-{m:02}-{d:02}"));
    trace!(format!("{y:04}-{m:02}-{d:02}"), "enter");
    trace!(format!("{y:04}-{m:02}-{d:02}"), "leave");

    leave!();
}

More


lib.rs:

dmacro: implemente function macro and debug macro and trace macro and log macro for Rust

This module contains the runtime support for the function! syntax extension. And also three useful macros trace!, enter!, leave! are implemented here. This module contains simple and personal implementation of function macro function! and debug macro trace! and trace macro trace! and log macro trace! for Rust

Define C-like debug trace macro: enter!() and leave!().

Check crate: https://crates.io/crates/dmacro

Thanks to https://stackoverflow.com/questions/38088067.

Example

use dmacro::*;

fn main() {
    enter!();
    println!("Hello, world!");

    trace!();
    trace!("church11");
    trace!("church21", "church22",);
    trace!("church31", "church32", "church33");
    trace!("church31", "church32", "church33", 1024);
    let y = 2023;
    let m = 9;
    let d = 28;
    trace!(format!("{:04}-{:02}-{:02}", y, m, d));
    trace!(format!("{y:04}-{m:02}-{d:02}"));
    trace!(format!("{y:04}-{m:02}-{d:02}"), "enter");
    trace!(format!("{y:04}-{m:02}-{d:02}"), "leave");

    leave!();
}

More

- [https://crates.io/crates/trace](https://crates.io/crates/trace)

Dependencies

~1MB
~18K SLoC