3Hren / 3Hren/blacklog

Common logging macro

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
P: normal T: enhancement T: perf T: refactor
Dominant language
Rust
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Unfortunately I'm not good with writing compiler plugins, but seems like we can borrow most of libfmt code. The main problem - it's private...

I see the full syntax something like this:

``` rust
// Simple log without meta and formatting feature. The emitted message is &'static str to avoid unnecessary intermediate formatting.
log!(logger, 0, "le message");

// The emitted message is Arguments<'a>.
log!(logger, 0, "le message: {}, {1}, {name}", 42, 3.1415, name = "Jon Snow");

// With meta information.
log!(logger 0, "le message: {}", 42, {
trace: 100500,
path: "/home",
});

// With meta information, also a meta value is borrowed for formatting.
log!(logger 0, "le message: {}, {path}", 42, {
trace: 100500,
path: "/home",
});

// Which is expanded into:
logger.log(0, Arguments<'a> ["le message: ", &42, ", ", &"/home"], MetaList<'a>(&[Meta::new("trace", &100500), Meta::new("path", "/home")]);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.