Skip to content
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

feat: include support for logging maps and sets #11258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kuskoman
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

[Nest] 76153  - 03/10/2023, 10:59:02 AM     LOG [RandomContext] [object Map]
[Nest] 76153  - 03/10/2023, 10:59:02 AM     LOG [RandomContext] [object Set]
[Nest] 74793  - 03/10/2023, 10:56:39 AM     LOG [RandomContext] Object:
{
         "blah": "blah",
         "map": {}
}
[Nest] 74793  - 03/10/2023, 10:56:39 AM     LOG [RandomContext] Object:
{
         "blah": "blah",
        "set": {}
}

Issue Number: #11189

What is the new behavior?

[Nest] 73354  - 03/10/2023, 10:54:11 AM     LOG [RandomContext] Map:
       {
         "foo": "bar",
         "rab": 123
      }
[Nest] 73354  - 03/10/2023, 10:54:11 AM     LOG [RandomContext] Set:
       [
         "foo",
         "bar",
         123
      ]
[Nest] 73354  - 03/10/2023, 10:54:11 AM     LOG [RandomContext] Object:
       {
         "blah": "blah",
         "set": [
           "foo",
           "bar",
           123
         ]
      }
[Nest] 73354  - 03/10/2023, 10:54:11 AM     LOG [RandomContext] Object:
       {
         "blah": "blah",
         "map": {
           "foo": "bar",
           "rab": 123
         }

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Unfortunately because the way of how JSON.stringify works making it:

"map": Map {
  "foo": "bar"
}

is pretty complex (same with set) and requires recursive parsing of objects, and excludes JSON.stringify replaces for some cases, so this RP treats Maps as objects and Sets as arrays when nested in logger.log call

@coveralls
Copy link

Pull Request Test Coverage Report for Build a9fdd683-6763-42d2-bcf8-b86b02553d72

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.885%

Totals Coverage Status
Change from base Build 691c6f82-b883-4c7f-a8c8-4e3b0232b333: 0.0%
Covered Lines: 6488
Relevant Lines: 6985

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec mentioned this pull request Mar 10, 2023
1 task
@kuskoman
Copy link
Author

@kamilmysliwiec what do you think about this PR? if you plan on adding it to one of the nestjs versions I can take some time and rebase it

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.

None yet

4 participants