-
Notifications
You must be signed in to change notification settings - Fork 158
feat(logger): introduce log key reordering functionality #2736
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
Merged
dreamorosi
merged 34 commits into
aws-powertools:main
from
arnabrahman:1568-log-message-ordering
Sep 9, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3a78c9a
feat: define `logRecordOrder` option in Logger types
arnabrahman a8dde6b
feat: pass the `logRecordOrder` option to `LogFormatter`
arnabrahman 4f3967f
feat: order attributes if logRecordOrder is available
arnabrahman c743eb0
feat: use `lodash.merge` for merging ordered & base order attributes
arnabrahman e1539ac
test: `logRecordOrder` option during formatting
arnabrahman 6115983
Merge branch 'main' into 1568-log-message-ordering
dreamorosi 94ed8fe
Merge branch 'main' into 1568-log-message-ordering
dreamorosi 7a6a7f1
feat: merge with main
arnabrahman e7be7a2
refactor: `LogRecordOrder` type union of `UnformattedAttributes` & `…
arnabrahman 22ab7b9
test: logRecordOrder option during formatting
arnabrahman 94b647f
refactor: replace `lodash.merge` wih native JS
arnabrahman e8014f4
test: `logRecordOrder` takes `additionalLogAttributes` into considera…
arnabrahman 80a2333
test: formatter when `logRecordOrder` is not set
arnabrahman 2dd0cc5
feat: during formatting, apply ordering for `additionalLogAttributes`…
arnabrahman 31efcec
test: `logRecordOrder` orders correctly when key doesn't even exist
arnabrahman 85ec8aa
test: `logRecordOrder` should be passed down to child logger
arnabrahman 986245c
doc: reordering log keys position
arnabrahman bd63350
doc: fix reorderLogKeys example highlight line
arnabrahman da1d0ee
feat: merge with main
arnabrahman f0ba54e
Merge branch '1568-log-message-ordering' of github.com:arnabrahman/aw…
arnabrahman e3bac06
doc: remove @returns
arnabrahman 1c6b2f6
Update packages/logger/src/Logger.ts
arnabrahman 07ba540
doc: update `setLogFormatter` function doc block
arnabrahman bfe9510
refactor: return early if `logRecordOrder` is not set
arnabrahman da62495
refactor: make `logRecordOrder` & `logFormatter` mutually exclusive
arnabrahman 4ae836c
refactor: use `logRecordOrder` only inside `PowertoolsLogFormatter` c…
arnabrahman 0a50ee5
test: refactor test to match the key orders
arnabrahman 37b43b2
refactor: extract unformattedAttributes to the top level
arnabrahman ce2cb90
test: update test to add uncovered line
arnabrahman 8f90b90
test: set `unformattedAttributes.timestamp` inside `beforeEach`
arnabrahman 735c650
doc: add callout
arnabrahman 62f0aef
style: doc block & afterAll cleanup for `unformattedAttributes`
arnabrahman 74f614f
test: refactor `logRecordOrder` test for child logger
arnabrahman f4d4220
Merge branch 'main' into 1568-log-message-ordering
dreamorosi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Logger } from '@aws-lambda-powertools/logger'; | ||
|
||
const logger = new Logger({ | ||
serviceName: 'serverlessAirline', | ||
logRecordOrder: ['timestamp', 'additionalKey'], | ||
}); | ||
|
||
export const handler = async (): Promise<void> => { | ||
logger.info('Hello, World!', { | ||
additionalKey: 'additionalValue', | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"timestamp": "2024-09-03T02:59:06.603Z", | ||
"additionalKey": "additionalValue", | ||
"level": "INFO", | ||
"message": "Hello, World!", | ||
"sampling_rate": 0, | ||
"service": "serverlessAirline", | ||
"xray_trace_id": "1-66d67b7a-79bc7b2346b32af01b437cf8" | ||
} |
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
arnabrahman marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.