Skip to content

Add a ldbg! macro that mirrors std::dbg #546

Open
@tgross35

Description

The std::dbg!() macro is quite useful for quick debugging. I have stumbled across at least a handful of cases where whatever the logger is is more useful than stderr output - for example, when the logger is mapped to RTT or UART on embedded and there is no stderr available.

So, my suggestion is to add ldbg that acts similarly to the debug macro, but uses the default logger.

use log::{ldbg, Level};

let v = vec![0usize, 1, 2, 3, 4];

// default to debug level (possibly warn or info so it's more likely to show up)
let m = ldbg!(&v[2..]);

// allow for optional level override
let n = ldbg!(level: Level::Warn, &v[..3]);

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions