-
Notifications
You must be signed in to change notification settings - Fork 944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to format debug
as JSON output
#442
Comments
With v3, you'll be able to override the |
Well, overriding the functionality of |
Well, a major goal of debug is to be minimal while also extensible. If you have a case where you need to write to a file, or write JSON to stdout, or move data to logstash via HTTP, debug should be able to support that without including the functionality into the core lib |
How .. ? |
The mere fact that the output can be multiline makes it impossible parse the logs in any reliable way. |
Overwriting |
That requires to have access to the |
I mean, by default, you aren't going to see any output if you are dealing with third-party libs. If you care about the output from third-party libs, and want a special format, it doesn't seem like a stretch to require you to install debug as a dep and overwrite the log function |
This is year 2020.
How do I format logs of |
If you really want to depend on overriding the output method, then use a global variable, e.g. // debug-format.js
global.visionmediaDebugOut = () => {}; Then whatever app that wants to override the Unlike the proposed approach, this approach can be work with multiple versions of debug in a backwards compatible way. I don't think thats a right approach. It is an overkill. Simply allowing to output content in JSON format using ENV as configuration would be enough. |
Well, using an env variable is good and all, but it requires additional surface area for the lib.... yet another configuration option that has to be well supported on every single platform running debug (node, all major browsers, electron, cordova, etc). |
Don't understand the argument. |
Standardized output to TTY and non-TTY interfaces on a variety of platforms with yet another output format isn't as simple as simply calling |
I'm looking for the same. Why the issue is closed?
This would fit to most of the log parsers that support JSON format logs. |
Please see #582. |
Thank you @Qix- but could you please show example how output could be converted to JSON? For those who is still need JSON as simple as it is, I'm checking this library: https://www.npmjs.com/package/pino But would be great to have simple support for JSON in debug library (I have already so many scripts done with "debug") For example something like this:
or this:
etc... |
@Kostanos please post on that ticket, not here. |
There is pino-debug. |
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.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.
The text was updated successfully, but these errors were encountered: