Pino rejecting a valid json format in case of error passed as object.
Opened this issue · 1 comments
jindalAnuj commented
this.logger.error({
type: LogType.error,
log: logPayload,
});
// log payload with type , complete json
{
type: 'Error',
log: {
message: 'Error occurred while getting vertical',
metadata: {
error: Error: Failed to list get verticals
at **********)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at **********)
}
}
}
// output
{"level":50,"time":1704439345847,"pid":72737,"hostname":"ip-192-168-1-34.ap-south-1.compute.internal","context":"OfflineVerticalService","type":"Error","log":{"message":"Error occurred while getting vertical","metadata":{"error":{}}}}
- as we can see error object is getting reject. This only happens in case of few error type like typeError
mcollina commented
Errors are special objects that must be manually serialized. I'm guessing that you have not installed a proper serializer for it (there is no reproduction in the OP, just a snippet).