Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Apr 23, 2025

Problem

If we want to log a large json object with giant strings (think whole files), it can make the logs difficult to read. This is especially relevant when the underlying string values are not very important.

Solution

  • allow the string values to be truncated with maxStringLength option.

Notes

I am planning to port this utility to Flare to improve the logging experience there, and want this functionality to exist there however I thought this could be useful here too.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions

This comment was marked as resolved.

@Hweinstock Hweinstock changed the title feat: add value length cap to partialClone feat(core): add value length cap to partialClone Apr 23, 2025
@Hweinstock Hweinstock closed this Apr 23, 2025
@Hweinstock Hweinstock reopened this Apr 23, 2025
@Hweinstock Hweinstock force-pushed the partialCloneValueCap branch from c57b32d to c0990b0 Compare April 23, 2025 23:02
describe('partialClone', function () {
it('omits properties by depth', function () {
const testObj = {
let multipleTypedObj: object
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is changed to avoid duplicate code lint fail.

@Hweinstock Hweinstock marked this pull request as ready for review April 23, 2025 23:15
@Hweinstock Hweinstock requested a review from a team as a code owner April 23, 2025 23:15
})
})

it('truncates properties by maxLength', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to also test when there are other non object types like number or boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout, I've adjusted the test to avoid only using strings.

@Hweinstock Hweinstock force-pushed the partialCloneValueCap branch from b0a3ea3 to c49b272 Compare April 24, 2025 10:55
@Hweinstock
Copy link
Contributor Author

failing test tracked in #7153

@Hweinstock Hweinstock merged commit 638778b into aws:master Apr 25, 2025
30 of 31 checks passed
@Hweinstock Hweinstock deleted the partialCloneValueCap branch April 25, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants