rust-lang / log

Logging implementation for Rust
https://docs.rs/log
Apache License 2.0
2.18k stars 252 forks source link

The design of kV is not concise enough, I have a simple suggestion. #604

Closed jmjoy closed 10 months ago

jmjoy commented 10 months ago

Just give as_*! add a grammar sugar. For example:

warn!(err = as_error!(err); "Unable to locate a razor, retrying");

also can be written:

warn!(error(err); "Unable to locate a razor, retrying");

For as_debug, as_display and others:

warn!(debug(err); "Unable to locate a razor, retrying");
warn!(display(err); "Unable to locate a razor, retrying");
Thomasdezeeuw commented 10 months ago

We're considering copying the shorthand of the tracing crate, starting roughly here: https://github.com/rust-lang/log/issues/328#issuecomment-1681786059. For example log::as_display(value) would be written as ?value. Would something like that work for you?

jmjoy commented 10 months ago

We're considering copying the shorthand of the tracing crate, starting roughly here: #328 (comment). For example log::as_display(value) would be written as ?value. Would something like that work for you?

Very good, thank you. I just saw that the log has a lot of formatting macros, such as serde and sval.