Macro loggy::log

source ·
macro_rules! log {
    ( $level:expr , $format:literal $( ; $( $tail:tt )* )? ) => { ... };
    ( $level:expr , $format:literal $( , $value:expr )* $( ; $( $tail:tt )* )? ) => { ... };
    ( @collect $string:ident , $indent:ident , $name:ident $( , )? ) => { ... };
    ( @collect $string:ident , $indent:ident , $name:ident , $( $tail:tt )* ) => { ... };
    ( @collect $string:ident, $indent:ident , $name:ident => $value:expr $( , )? ) => { ... };
    ( @collect $string:ident, $indent:ident , $name:ident => $value:expr , $( $tail:tt )* ) => { ... };
    ( @collect $string:ident , $indent:ident, $name:ident { $( $nest:tt )* } $( , )? ) => { ... };
    ( @collect $string:ident , $indent:ident, $name:ident { $( $nest:tt )* } , $( $tail:tt )* ) => { ... };
}
Expand description

Log a structured message.

Usage: log!(level, "some text {}", 1; field => value, label { sub_field => value }, ...) results in a log message:

some text:
  field: value
  label:
    sub field: value

This is an extension of the slog structured message format to support nesting. Note that here there’s no way to control the final message format, which was chosen to target human readability.