Skip to content

Add ability to format debug as JSON output #442

@gajus

Description

@gajus

I'd like there to be an option (controllable using environment variables) that would make debug module print JSON output instead of plain text.

This at the moment can be achieved using a module such as debug-to-json (@ping yoshuawuyts). The problem with the pipe solution is that it is not always easy to modify the command used to start the program (e.g. How to append an argument to a container command?).

Maybe I am doing something wrong, but (in a large deployment) logs coming via debug are quite useless ("large deployment" being a Kubernetes cluster with filebeat + ELK used for logging). [I suppose it is possible to reconize debug output in logstash and convert it to JSON?]

Being able to configure debug output with environment variable would greatly alleviate the difficulty of log processing here, e.g.

DEBUG_FORMAT=json

The other thing to note here is that certain log aggregation methods (filebeat) require that logs come in one-per-line. Plain text output does not guarantee this; JSON can.

Furthermore, the JSON format could be used to supplement debug output with meta information such as package name, version. This can be a controllable option via environment variables too.

I'd be happy to raise a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions