Giter Club home page Giter Club logo

Comments (6)

iamolegga avatar iamolegga commented on May 18, 2024 4

Good catch, thanks. I'll try to see what can be done here

from nestjs-pino.

kirit0s avatar kirit0s commented on May 18, 2024 3

Pino expects Error object in err field and can correctly serialize it.

Example:

this.logger.error({ err: new Error('message') })

from nestjs-pino.

iamolegga avatar iamolegga commented on May 18, 2024 1

Hi, it's interesting, could you please provide minimal example repo on this?

from nestjs-pino.

micalevisk avatar micalevisk commented on May 18, 2024 1

While testing the minimal example I figured out that this issue appear when I define the context to the PinoLogger instance. Without calling logger.setContext or using the @InjectPinoLogger decorator, this.logger.error(Error('foo')) show the error object.

You can download the example here: https://codesandbox.io/s/nestjs-pino-issue-304-lgxwv

from nestjs-pino.

iamolegga avatar iamolegga commented on May 18, 2024 1

Added extra check if passing instance of Error, and if so transfering it to err field. Anyway that's more related to pino than to this lib. if you passing some custom error please check this out: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work. Also this issue might be useful too: pinojs/pino#579

shipped in v1.3.0

from nestjs-pino.

micalevisk avatar micalevisk commented on May 18, 2024

I just realize this is a bug :/

This happen due to the following code

Object.assign({ [this.contextName]: context }, firstArg),

because in my case firstArg has non-enumerable props (stack and message) so they aren't copied to the new object created there. Besides that, the first arg will no longer be recognized as an error instance so Pino will not serialized that properly I guess.

from nestjs-pino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.