Closed winksaville closed 1 month ago
You should use serializers.
You should use serializers.
Do you mean these https://github.com/pinojs/pino-std-serializers or do you mean create per object custom serializes or something else?
Note; in my example I'm pointing out that the "default" serialization to a string that console.log uses for arbitrary Objects (first-level properties) seems much friendlier/convenient than the default in pino (all properties). Is there a way to adopt the approach used by console.log as a default serializer for Objects in general. Maybe such a mechanism already exists for me, the user, to override the current default serialization for each of JavaScript fundamental types?
Note.Note: I'm a relative js noob so I am very likely confused and suggesting some totally stupid, please pardon my ignorance :)
console.log()
uses utils.inspect()
internally:
https://nodejs.org/dist/latest-v18.x/docs/api/util.html#utilinspectobject-showhidden-depth-colors
Note that the output is not JSON. It indicates "skipped" objects with ...
. This same behavior is not possible with JSON, so those properties will be completely skipped.
I'm not looking for exactly the same behavior. I'm just thinking it'd be nice if the pino default was simpler. The flp() function seems good enough to for now, TXS!
Pino is designed for recording logs in applications used in a "production" scenario. The defaults are designed to provide the information necessary in such a case.
IMO, logging is used through the dev cycle and that's why there are features such as levels. In addition, a default is just that, a default, and is intended to be overridden if inappropriate for the current situation. I suggest the current is overly verbose, definitely arguable. But not being able to easily and efficiently change the default seems a significant short coming.
Would a feature request be considered or a waste of my time? If I were to make the request I would also consider providing a PoC implementation, although I'd appreciate guidance on how to proceed.
It is configurable. The documentation for the configuration was linked by Matteo. Please read it.
It is configurable. The documentation for the configuration was linked by Matteo. Please read it.
AFAICT @mcollina provided two links
Neither appear to me to refer to a default global serializer.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm testing pino:
I like what I see, but I have one problem. When I use console.log to log the contents of an object the default output is the first level of that objects contents. For example:
This output is ok and has 636 characters:
But if I enable just pino log.info in the little app it outputs 10,0020 characters:
I had a conversation with GPT4o and there is a way to get the similar output using pino, it suggested something like:
Is there a way to have something like
flp()
be the default serializer for objects?