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(types): add responseTime parameter to customErrorMessage #358

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

Conversation

MarcusHong
Copy link

Description

Add responseTime parameter to customErrorMessage type definition to allow access to the request's response time when creating custom error messages.

Changes

  • Updated TypeScript type definition for customErrorMessage to include responseTime parameter
  • Response time is provided in milliseconds, consistent with pino-http's existing timing

Example Usage

const logger = pinoHttp({
  customErrorMessage: (req, res, err, responseTime) => {
    return `${err.message} (took ${responseTime}ms)`;
  }
});

@mcollina
Copy link
Member

Thanks for opening a PR! Can you please add a unit test? We use tsd for the types

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.

2 participants