-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
serializeMessage should support format characters #25
Comments
Hmmm. Even though I know quite a few people prefer the string interpolation notation, I never could understand why; guess it's a matter of taste (and you can't argue about that). As for helix log, I decided at the very beginning, that supporting that style of string interpolation for the basic interface was a non-goal; there where a couple of reasons for this:
I mean, look at the weirdness of the following logging statement in bunyan:
In the end though it was my personal distaste for the interface that affected the decision the most and I guess it's bad style to expect other people to abide by my tastes; so, I suggest we create a If the feature turns out to be popular or if we find such an adapter to be too cumbersome I would also be open to an |
true...
well, console.log indeed supports string interpolation; otherwise it would not suggest it:
in the end, I would just rely on https://nodejs.org/api/util.html#util_util_format_format_args. We could go with a special interface for this, but I don't see a benefit of not having string interpolation. |
Jesus, you're right. |
Do you want to take this and add it to logWithOpts? |
it would be nice if you can take care of this...especially if you plan to refactor code for the data-logging.... :-) |
I've looked at how hard implementing this (while preserving helix-log features such as exception-safety) would be, and unfortunately the answer is: Quite hard. util.format is not really exception safe (I found ways to trigger exceptions on It can be done, but honestly I would not like to see in the core interface of helix-log. Since we now have the Interface concept, feel free to provide a BunyanLikeInterface and/or ConsoleLikeInterface. |
serializeMessage
should support string format characters, similar toconsole.log
:example:
as a consequence, I think the
messageFormatJson
should be smart about how many parameters it consumes from the arguments during serializing the mesage, eg:would generate:
The text was updated successfully, but these errors were encountered: