Skip to content

Commit

Permalink
chore(errors): better logging for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcrea committed Nov 14, 2024
1 parent a06080c commit b3df9da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/prettifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ export const build = (options: PinoPretty.PrettyOptions) => {
}
// Message or error
const firstErrorKey = errorLikeObjectKeys.find((key) => log[key]);
const formattedMsg = colorMsgForLevel(level)(String(log[messageKey]));
if (firstErrorKey) {
const error = log[firstErrorKey];
const serializedError = isSerializedError(error) ? error : serializeError(error);
output.push(formattedMsg, EOL, " ", formatError(serializedError, level), EOL);
output.push(formatError(serializedError, level), EOL);
} else {
const formattedMsg = colorMsgForLevel(level)(String(log[messageKey]));
output.push(formattedMsg);
}
// Fastify plugin name
Expand All @@ -89,7 +89,7 @@ export const build = (options: PinoPretty.PrettyOptions) => {
}
// Other props
const outputProps = Object.keys(otherProps).reduce<Record<string, unknown>>((soFar, key) => {
if (errorLikeObjectKeys.includes(key) || ignoredKeys.includes(key)) {
if (errorLikeObjectKeys.includes(key) || ignoredKeys.includes(key) || ["req", "res"].includes(key)) {
return soFar;
}
soFar[key] = otherProps[key];
Expand Down

0 comments on commit b3df9da

Please sign in to comment.