nest icon indicating copy to clipboard operation
nest copied to clipboard

feat(common): Support JSON format in ConsoleLogger

Open nesro opened this issue 1 year ago • 3 comments
trafficstars

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] Docs have been added / updated (for bug fixes / features)

ConsoleLoggerOptions interface has the new option asJSON with a JSDoc comment

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [x] 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?

Currently, there is no way to make ConsoleLogger log JSON strings

Issue Number: N/A

What is the new behavior?

Now there is a option to log as JSON string

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

There is this issue https://github.com/nestjs/nest/issues/10342 that is closed, but still there is no support for JSON string format.

We are in a need of JSON string logs - it's easier to parse in Google Cloud and there are less problems with newlines.

Some projects that handle this issue exists:

  • https://github.com/igrek8/gc-json-logger-nestjs
  • https://github.com/marciopd/json-logger-service but they doesn't seems to be updated. And I think a basic form of this functionality should be provided without external library.

nesro avatar May 11 '24 21:05 nesro

Pull Request Test Coverage Report for Build 579eb5c0-6c1b-4f78-90af-24910b29a78e

Details

  • 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.124%

Totals Coverage Status
Change from base Build c5951846-b9c8-4626-baf3-314800754e97: 0.0%
Covered Lines: 6737
Relevant Lines: 7313

💛 - Coveralls

coveralls avatar May 11 '24 21:05 coveralls

Is there any movement on this? I'm looking into adding a JSON logger for my app and would much rather use something built into Nest.

Buzzkill-McSquare avatar Sep 12 '24 15:09 Buzzkill-McSquare

@Buzzkill-McSquare sorry I'm busy elsewhere. I want to get back to this, but as we decided to use Pino, this isn't high priority anymore.

We wanted to use something built-in as well, but I can only recommend Pino.

nesro avatar Sep 12 '24 20:09 nesro