Skip to content

quote value in ConsoleRender like LogfmtRenderer for special chars #647

@trim21

Description

@trim21

logger.info("hello", a="1 b=2") will be logged as hello1 a=1 b=2 and may cause some problem, maybe we should quote value when it contain any space

for example:

class _ConsoleRender(structlog.dev.ConsoleRenderer):

    def _repr(self, val: Any) -> str:
        v = str(val)
        if " " in v or '\n' in v:
            return repr(v)

        return v

or just return repr(val)

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