-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hey there,
I don't think that using JSON objects is the best choice for structured logging at all. In my opinion, JSON arrays are more suited:
- They are easily parsed by
JSON.parse
and all major JSON toold as well - They are faster to parse
- They are faster to stringify
- They are more lightweight
I agree that the payload should be any object the user provides, but using objects for the root log record does not sound well for me.
Yes, the negative is that arrays are not as human readable as objects are, but with a first field specifying the schema version, it's just as machine readable.
And command-line filters using JSON agnostic tools (e.g. jq
) should be just as easy as for objects.
Thus, if a unified standard would be crafted, I highly prefer arrays over objects; as I do use them within my logging library oddlog. And yes, I'm not sure how to include it within the readme because of the array-based log record format.
But since it's not used by any other library that I know of, I highly doubt that this would succeed 😿