diff --git a/src/cli/reset.js b/src/cli/reset.js index d3675d2ee4..33b1f01601 100644 --- a/src/cli/reset.js +++ b/src/cli/reset.js @@ -151,7 +151,7 @@ function resetPlugin(pluginId, callback) { }, ], function (err) { if (err) { - winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err); + winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err); } else if (active) { winston.info('[reset] Plugin `%s` disabled', pluginId); } else { diff --git a/src/prestart.js b/src/prestart.js index f9d9e20cd7..a310321028 100644 --- a/src/prestart.js +++ b/src/prestart.js @@ -12,6 +12,22 @@ function setupWinston() { if (!winston.format) { return; } + + // allow winton.error to log error objects properly + // https://github.com/NodeBB/NodeBB/issues/6848 + const winstonError = winston.error; + winston.error = function (msg, error) { + if (msg instanceof Error) { + winstonError(msg); + } else if (error instanceof Error) { + msg = msg + '\n' + error.stack; + winstonError(msg); + } else { + winstonError.apply(null, arguments); + } + }; + + // https://github.com/winstonjs/winston/issues/1338 // error objects are not displayed properly const enumerateErrorFormat = winston.format((info) => {