Skip to main content

rs_utils/log/kv/
mod.rs

1//! The usual key-value format for log macros is to put the keys before the message, the
2//! macros in this module reverse this order so that the log message comes before the
3//! key/value pairs.
4
5#[cfg(feature="env-logger-format")]
6#[cfg_attr(docsrs, doc(cfg(feature="env-logger-format")))]
7pub mod format;
8#[cfg(feature="env-logger-format")]
9#[cfg_attr(docsrs, doc(cfg(feature="env-logger-format")))]
10pub use self::format::*;
11
12pub use log::LevelFilter;
13
14/// Log trace message with key values after the message instead of before
15pub macro trace {
16  ($fmtstring:expr$(, $fmtarg:expr)*$(; $($kvargs:tt)*)?) => {
17    super::trace!($($($kvargs)*;)? $fmtstring$(, $fmtarg)*)
18  }
19}
20/// Log debug message with key values after the message instead of before
21pub macro debug {
22  ($fmtstring:expr$(, $fmtarg:expr)*$(; $($kvargs:tt)*)?) => {
23    super::debug!($($($kvargs)*;)? $fmtstring$(, $fmtarg)*)
24  }
25}
26/// Log info message with key values after the message instead of before
27pub macro info {
28  ($fmtstring:expr$(, $fmtarg:expr)*$(; $($kvargs:tt)*)?) => {
29    super::info!($($($kvargs)*;)? $fmtstring$(, $fmtarg)*)
30  }
31}
32/// Log warn message with key values after the message instead of before
33pub macro warn {
34  ($fmtstring:expr$(, $fmtarg:expr)*$(; $($kvargs:tt)*)?) => {
35    super::warn!($($($kvargs)*;)? $fmtstring$(, $fmtarg)*)
36  }
37}
38/// Log error message with key values after the message instead of before
39pub macro error {
40  ($fmtstring:expr$(, $fmtarg:expr)*$(; $($kvargs:tt)*)?) => {
41    super::error!($($($kvargs)*;)? $fmtstring$(, $fmtarg)*)
42  }
43}