#trace #macro #debugging #log #function-macro

dmacro

定义类似于C的调试跟踪宏:enter!()和leave!()

4个版本

0.1.9 2023年10月16日
0.1.8 2023年10月16日
0.1.5 2023年9月28日

#224 in 过程宏

每月下载量50

MIT许可证

7KB
90

定义类似于C的调试跟踪宏:enter!()leave!()

查看crate:https://crates.io/crates/dmacro

感谢https://stackoverflow.com/questions/38088067

示例

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!();
}

更多


lib.rs:

dmacro:为Rust实现函数宏、调试宏、跟踪宏和日志宏

此模块包含对function!语法扩展的运行时支持。还实现了三个有用的宏:trace!enter!leave!。此模块包含对函数宏function!、调试宏trace!、跟踪宏trace!和日志宏trace!的简单和个性化实现。

定义类似于C的调试跟踪宏:enter!()leave!()

查看crate:https://crates.io/crates/dmacro

感谢https://stackoverflow.com/questions/38088067

示例

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!();
}

更多

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

依赖

~1MB
~18K SLoC