diff --git a/index.d.ts b/index.d.ts index c7c482d..984061a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -31,7 +31,7 @@ export interface Options pino.LevelWithSilent | CustomLevels) | undefined; customReceivedMessage?: ((req: IM, res: SR) => string) | undefined; customSuccessMessage?: ((req: IM, res: SR, responseTime: number) => string) | undefined; - customErrorMessage?: ((req: IM, res: SR, error: Error) => string) | undefined; + customErrorMessage?: ((req: IM, res: SR, error: Error, responseTime: number) => string) | undefined; customReceivedObject?: ((req: IM, res: SR, val?: any) => any) | undefined; customSuccessObject?: ((req: IM, res: SR, val: any) => any) | undefined; customErrorObject?: ((req: IM, res: SR, error: Error, val: any) => any) | undefined; diff --git a/index.test-d.ts b/index.test-d.ts index 8b10fb1..da8c7a3 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -46,8 +46,9 @@ pinoHttp({ customSuccessMessage: (req: IncomingMessage, res: ServerResponse) => pinoHttp({ customSuccessMessage: (req: CustomRequest, res: CustomResponse) => 'Success' }); // #customErrorMessage -pinoHttp({ customErrorMessage: (req: IncomingMessage, res: ServerResponse, error: Error) => `Error - ${error}` }); -pinoHttp({ customErrorMessage: (req: CustomRequest, res: CustomResponse, error: Error) => `Error - ${error}` }); +pinoHttp({ customErrorMessage: (req: IncomingMessage, res: ServerResponse, error: Error, responseTime:number) => `Error - ${error.message} after ${responseTime}ms` }); +pinoHttp({ customErrorMessage: (req: CustomRequest, res: CustomResponse, error: Error, responseTime:number) => `Error - ${error.message} after ${responseTime}ms` }); + // #customAttributeKeys pinoHttp({ customAttributeKeys: { req: 'req' } }); @@ -150,7 +151,7 @@ const options: Options = { return `Received HTTP ${req.httpVersion} ${req.method}`; }), customSuccessMessage: canBeUndefined((req: IncomingMessage, res: ServerResponse) => 'successMessage'), - customErrorMessage: canBeUndefined((req: IncomingMessage, res: ServerResponse, error: Error) => 'errorMessage'), + customErrorMessage: canBeUndefined((req: IncomingMessage, res: ServerResponse, error: Error, responseTime: number) => 'errorMessage'), customAttributeKeys: canBeUndefined(customAttributeKeys), wrapSerializers: canBeUndefined(rtnBool()), customProps: canBeUndefined((req: IncomingMessage, res: ServerResponse) => ({} as object)),