pino-http icon indicating copy to clipboard operation
pino-http copied to clipboard

feat(types): add responseTime parameter to customErrorMessage

Open MarcusHong opened this issue 1 year ago • 1 comments

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)`;
  }
});

MarcusHong avatar Nov 22 '24 03:11 MarcusHong

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

mcollina avatar Nov 22 '24 14:11 mcollina