fix: winston usages

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 414caac01b
commit b8cafefce2

@ -45,6 +45,8 @@ prestart.setupWinston();
prestart.versionCheck();
winston.verbose('* using configuration stored in: %s', configFile);
winston.error('oppps we faled', new Error('yah'));
if (!process.send) {
// If run using `node app`, log GNU copyright info along with server info
winston.info('NodeBB v' + nconf.get('version') + ' Copyright (C) 2013-' + (new Date()).getFullYear() + ' NodeBB Inc.');

@ -139,7 +139,7 @@ Analytics.writeData = async function () {
try {
await Promise.all(dbQueue);
} catch (err) {
winston.error('[analytics] Encountered error while writing analytics to data store', err.stack);
winston.error('[analytics] Encountered error while writing analytics to data store\n' + err.stack);
throw err;
}
};

@ -133,7 +133,7 @@ async function resetPlugin(pluginId) {
winston.info('[reset] No action taken.');
}
} catch (err) {
winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err.stack);
winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s\n' + err.stack);
throw err;
}
}

@ -69,7 +69,7 @@ async function getLatestVersion() {
try {
return await versions.getLatestVersion();
} catch (err) {
winston.error('[acp] Failed to fetch latest version', err.stack);
winston.error('[acp] Failed to fetch latest version\n' + err.stack);
}
return null;
}

@ -40,7 +40,7 @@ redisModule.init = function (callback) {
callback = callback || function () { };
redisModule.client = connection.connect(nconf.get('redis'), function (err) {
if (err) {
winston.error('NodeBB could not connect to your Redis database. Redis returned the following error', err.stack);
winston.error('NodeBB could not connect to your Redis database. Redis returned the following error\n' + err.stack);
return callback(err);
}
require('./redis/promisify')(redisModule.client);

@ -58,7 +58,7 @@ connection.connect = function (options, callback) {
if (dbIdx >= 0) {
cxn.select(dbIdx, function (err) {
if (err) {
winston.error('NodeBB could not select Redis database. Redis returned the following error', err.stack);
winston.error('NodeBB could not select Redis database. Redis returned the following error\n' + err.stack);
throw err;
}
});

@ -79,7 +79,7 @@ Flags.init = async function () {
const data = await plugins.hooks.fire('filter:flags.getFilters', hookData);
Flags._filters = data.filters;
} catch (err) {
winston.error('[flags/init] Could not retrieve filters', err.stack);
winston.error('[flags/init] Could not retrieve filters\n' + err.stack);
Flags._filters = {};
}
};

@ -333,7 +333,7 @@ Notifications.prune = async function () {
}, { batch: 500, interval: 100 });
} catch (err) {
if (err) {
winston.error('Encountered error pruning notifications', err.stack);
winston.error('Encountered error pruning notifications\n' + err.stack);
}
}
};

@ -13,6 +13,20 @@ function setupWinston() {
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);
// }
// };
var formats = [];
if (nconf.get('log-colorize') !== 'false') {
formats.push(winston.format.colorize());

@ -278,7 +278,7 @@ function listen(callback) {
oldUmask = process.umask('0000');
module.exports.testSocket(socketPath, function (err) {
if (err) {
winston.error('[startup] NodeBB was unable to secure domain socket access (' + socketPath + ')', err.stack);
winston.error('[startup] NodeBB was unable to secure domain socket access (' + socketPath + ')\n' + err.stack);
throw err;
}

Loading…
Cancel
Save