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

error serializer question #906

Closed
naseemkullah opened this issue Sep 9, 2020 · 6 comments
Closed

error serializer question #906

naseemkullah opened this issue Sep 9, 2020 · 6 comments

Comments

@naseemkullah
Copy link
Contributor

Is it possible to serialize an error err such that instead of the stack trace being (only) in err.stack it is (also) in a top level stack_trace property? If so, how?

@naseemkullah
Copy link
Contributor Author

This will come in handy for the google cloud pino plugin if it ever gets made: googleapis/nodejs-logging#875 (comment)

But I would use this config at our org in the meantime.

@mcollina
Copy link
Member

This is not currently possible without some significant manipulation of config file. I think you can use the log formatter to do so.

@naseemkullah
Copy link
Contributor Author

naseemkullah commented Sep 10, 2020

Ah, so instead of playing with the error serializer, you would suggest something like the following?

    log(object) {
      const stackTraceProp = object?.err?.stack
        ? {stack_trace: object.err.stack}
        : {};

      return {
        ...object,
        ...stackTraceProp,
      };

@mcollina
Copy link
Member

formatter, not serializer.

That's the only way to do what you'd like to do.

@naseemkullah
Copy link
Contributor Author

Alright thanks!

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants