mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: winston usages
This commit is contained in:
2
app.js
2
app.js
@@ -45,6 +45,8 @@ prestart.setupWinston();
|
|||||||
prestart.versionCheck();
|
prestart.versionCheck();
|
||||||
winston.verbose('* using configuration stored in: %s', configFile);
|
winston.verbose('* using configuration stored in: %s', configFile);
|
||||||
|
|
||||||
|
winston.error('oppps we faled', new Error('yah'));
|
||||||
|
|
||||||
if (!process.send) {
|
if (!process.send) {
|
||||||
// If run using `node app`, log GNU copyright info along with server info
|
// 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.');
|
winston.info('NodeBB v' + nconf.get('version') + ' Copyright (C) 2013-' + (new Date()).getFullYear() + ' NodeBB Inc.');
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ Analytics.writeData = async function () {
|
|||||||
try {
|
try {
|
||||||
await Promise.all(dbQueue);
|
await Promise.all(dbQueue);
|
||||||
} catch (err) {
|
} 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;
|
throw err;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ async function resetPlugin(pluginId) {
|
|||||||
winston.info('[reset] No action taken.');
|
winston.info('[reset] No action taken.');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ async function getLatestVersion() {
|
|||||||
try {
|
try {
|
||||||
return await versions.getLatestVersion();
|
return await versions.getLatestVersion();
|
||||||
} catch (err) {
|
} 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ redisModule.init = function (callback) {
|
|||||||
callback = callback || function () { };
|
callback = callback || function () { };
|
||||||
redisModule.client = connection.connect(nconf.get('redis'), function (err) {
|
redisModule.client = connection.connect(nconf.get('redis'), function (err) {
|
||||||
if (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);
|
return callback(err);
|
||||||
}
|
}
|
||||||
require('./redis/promisify')(redisModule.client);
|
require('./redis/promisify')(redisModule.client);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ connection.connect = function (options, callback) {
|
|||||||
if (dbIdx >= 0) {
|
if (dbIdx >= 0) {
|
||||||
cxn.select(dbIdx, function (err) {
|
cxn.select(dbIdx, function (err) {
|
||||||
if (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;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ Flags.init = async function () {
|
|||||||
const data = await plugins.hooks.fire('filter:flags.getFilters', hookData);
|
const data = await plugins.hooks.fire('filter:flags.getFilters', hookData);
|
||||||
Flags._filters = data.filters;
|
Flags._filters = data.filters;
|
||||||
} catch (err) {
|
} 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 = {};
|
Flags._filters = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ Notifications.prune = async function () {
|
|||||||
}, { batch: 500, interval: 100 });
|
}, { batch: 500, interval: 100 });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (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;
|
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 = [];
|
var formats = [];
|
||||||
if (nconf.get('log-colorize') !== 'false') {
|
if (nconf.get('log-colorize') !== 'false') {
|
||||||
formats.push(winston.format.colorize());
|
formats.push(winston.format.colorize());
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ function listen(callback) {
|
|||||||
oldUmask = process.umask('0000');
|
oldUmask = process.umask('0000');
|
||||||
module.exports.testSocket(socketPath, function (err) {
|
module.exports.testSocket(socketPath, function (err) {
|
||||||
if (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;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user