Skip to content

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