Skip to content

Escape Backslashes #15

@Feuermurmel

Description

@Feuermurmel

Description

Quote backslashes to 1) resolve parsing issues with external tools 2) disambiguate quoting logic.

Why

External Tool Parsing

Grafana's logfmt parser doesn't accept e.g. foo="\". It simply discards the pair:

PASS

{...} | line_format "foo=\"\\\"" | logfmt

FAIL

{...} | line_format "foo=\"\\\\\"" | logfmt

Ambiguous Quoting

Several kinds of string are quoted to exactly the same value, making it impossible to undo the quoting. Specifically, looking at https://github.com/josheppinette/python-logfmter/blob/main/src/logfmter/formatter.py#L44 , the following pairs of strings quote to the same values:

  • " and \" -> \"
  • newline and \n -> \n

This makes it impossible to recover the input strings. A simple change would solve this: require backslashes on input to also be quoted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions