fix: support nested timestampKey and messageKey paths - #678
Open
kilisamemarisaaa wants to merge 1 commit into
Open
fix: support nested timestampKey and messageKey paths#678kilisamemarisaaa wants to merge 1 commit into
kilisamemarisaaa wants to merge 1 commit into
Conversation
levelKey already resolved nested/escaped property paths via getPropertyValue. timestampKey and messageKey still used top-level property access, so values under pino nestedKey (e.g. nested_key.time) were ignored. Use getPropertyValue for both keys, delete rendered nested paths from the object dump (and prune empty parents), and document the same delimiter/escape rules as levelKey. Fixes pinojs#438 Co-Authored-By: EvoX <evox@evomap.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #438.
levelKeyalready supports nested / escaped property paths viagetPropertyValue.timestampKeyandmessageKeystill used top-level access (key in log/log[key]), so timestamps under PinonestedKey(e.g.nested_key.time) were ignored and never prettified.This PR aligns
timestampKeyandmessageKeywith the same path rules aslevelKey, and removes those rendered values from the leftover object dump (including pruning empty parent objects so you do not getnested_key: {}).Changes
lib/utils/prettify-time.js— resolvetimestampKeywithgetPropertyValue; keeptimestampfallback when configured key is absentlib/utils/prettify-message.js— resolvemessageKeywithgetPropertyValuelib/pretty.js— skip already-rendered message/level/time paths for nested keys when dumping the objectReadme.md— document nested path support for--timestampKey/--messageKeyTest plan
node --test lib/utils/prettify-time.test.js lib/utils/prettify-message.test.js— 39/39 passnode --test test/basic.test.js— 75/75 passnode --test test/error-objects.test.js— 16/16 passnode --test test/cli.test.js— 42/42 passnode --test lib/utils/get-property-value.test.js lib/utils/prettify-level.test.js— passnpx eslinton touched JS files — clean@timestampregression;time: 0; missing nested path does not steal roottime; object dump does not repeat nested time/messageSelf-review checklist (≥10)
levelKey/getPropertyValueconventionstimestampfallback preserved when configured key missingtimetime: 0still works