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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: avoid undefined message in utilities #816

Merged
merged 1 commit into from
May 13, 2024

Conversation

HungThinhIT
Copy link
Contributor

@HungThinhIT HungThinhIT commented Apr 24, 2024

馃敡 Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Codebase improvement
  • Other (if none of the other choices apply)

馃毃 Checklist

  • I've read the guidelines for contributing
  • I've added necessary documentation (if appropriate)
  • I've ensured that my code additions do not fail linting or unit tests (if applicable)

Description

When we use logger at interceptor without message, and attach an object directly into .log function such as:

this.logger.log(
  {
   // message: "it should be here, but i wanna try without this field to reproduce undefined case."
    fields: {
      method: "GET",
      userAgent: "my-ua",
      ...
    },
  },
  context.getClass().name
);

The output in console transport will appear undefined due to message is undefined :

[NESTJS] Info 4/24/2024, 3:36:42 PM [MyController] undefined - {
  fields: {
     method: "GET",
     userAgent: "my-ua",
} +2m

Therefore, this PR that simple check message variable before it can appear in the console.

@drdreo
Copy link

drdreo commented May 13, 2024

Yes please, this discrepancy is annoying

@gremo gremo merged commit b5ff038 into gremo:main May 13, 2024
@gremo
Copy link
Owner

gremo commented May 13, 2024

Thank you @HungThinhIT !

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

3 participants