-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Description
I am trying to provide a custom messageFormat option to display the error stack from a new line, but the new lines are replaced with a single space.
Options:
options: {
ignore: 'pid,hostname,context,err',
messageFormat: `[{context}] {msg}{if err.stack}\n{err.stack}{end}`,
},Example:
const myError = new Error('Something went wrong');
logger.error(`An error occurred: ${myError.message}`, myError.stack);
Output:
[18:31:29.781] ERROR: [Test] An error occurred: Something went wrong Error: Something went wrong
at bootstrap (/dist/apps/test/webpack:/node-trading-robot/apps/test/src/main.ts:26:19)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
Expected output:
[18:31:29.781] ERROR: [Test] An error occurred: Something went wrong
Error: Something went wrong
at bootstrap (/dist/apps/test/webpack:/node-trading-robot/apps/test/src/main.ts:26:19)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
Seems like new lines are replaced on purpose, but is there a way to allow them?
PS: If I put the new line in the log message itself, it works as expected.
Example:
const myError = new Error('Something went wrong');
logger.error(`An error occurred: ${myError.message}\n`, myError.stack);Output:
[18:31:29.781] ERROR: [Test] An error occurred: Something went wrong
Error: Something went wrong
at bootstrap (/dist/apps/test/webpack:/node-trading-robot/apps/test/src/main.ts:26:19)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
Metadata
Metadata
Assignees
Labels
No labels