Moar better logging

This commit is contained in:
Bryan Ashby 2022-08-13 18:13:30 -06:00
parent a48f2b4067
commit 56f03ff847
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
2 changed files with 25 additions and 11 deletions

View File

@ -90,9 +90,9 @@ module.exports = class LoginServerModule extends ServerModule {
client.on('idle timeout', idleLogoutSeconds => { client.on('idle timeout', idleLogoutSeconds => {
client.log.info( client.log.info(
`Node ${client.node} idle timeout (${moment `Node ${client.node} idle timeout of ${moment
.duration(idleLogoutSeconds, 'seconds') .duration(idleLogoutSeconds, 'seconds')
.humanize()}) expired; Kicking` .humanize()} expired; Kicking`
); );
client.menuStack.goto('idleLogoff', err => { client.menuStack.goto('idleLogoff', err => {

View File

@ -1678,9 +1678,7 @@ function FTNMessageScanTossModule() {
self.appendTearAndOrigin(message); self.appendTearAndOrigin(message);
const importConfig = { const importConfig = { localAreaTag };
localAreaTag: localAreaTag,
};
self.importMailToArea(importConfig, packetHeader, message, err => { self.importMailToArea(importConfig, packetHeader, message, err => {
if (err) { if (err) {
@ -1702,7 +1700,7 @@ function FTNMessageScanTossModule() {
uuid: message.messageUuid, uuid: message.messageUuid,
MSGID: msgId, MSGID: msgId,
}, },
`Not importing non-unique message "${message.subject}"` `Not importing non-unique message ${localAreaTag}: "${message.subject}"`
); );
return next(null); return next(null);
@ -1721,16 +1719,32 @@ function FTNMessageScanTossModule() {
// //
// try to produce something helpful in the log // try to produce something helpful in the log
// //
const makeCount = obj => {
return obj
? _.reduce(
obj,
(sum, c) => {
return sum + c;
},
0
)
: 0;
};
const finalStats = Object.assign(importStats, { packetPath: packetPath }); const finalStats = Object.assign(importStats, { packetPath: packetPath });
if (err || Object.keys(finalStats.areaFail).length > 0) { const totalFail = makeCount(finalStats.areaFail) + finalStats.otherFail;
if (err || totalFail > 0) {
if (err) { if (err) {
Object.assign(finalStats, { error: err.message }); Object.assign(finalStats, { error: err.message });
} }
Log.warn(finalStats, `Import completed with ${totalFail} error(s)`);
Log.warn(finalStats, 'Import completed with error(s)');
} else { } else {
// :TODO: Output basic stats - total counts - to this message: const totalSuccess = makeCount(finalStats.areaSuccess);
Log.info(finalStats, 'Import complete'); Log.info(
finalStats,
`Import completed successfully with ${totalSuccess} messages`
);
} }
cb(err); cb(err);