Skip to main content

parse_logfmt

Function parse_logfmt 

Source
fn parse_logfmt(line: &str) -> Result<BTreeMap<KeyString, Value>, String>
Expand description

Parses a logfmt line into key-value pairs.

Follows the grammar used by common logfmt implementations (e.g. go-logfmt):

  • pairs are separated by whitespace;
  • a key is a run of printable characters other than =, " and whitespace;
  • a value is either unquoted (ends at the next whitespace) or double-quoted, where \", \\, \n, \r, \t, \/, \b, \f and \uXXXX escapes are supported;
  • key= yields an empty string and a bare key yields true.