Better logging

This commit is contained in:
Bryan Ashby 2018-09-11 14:44:22 -06:00
parent 4501759d99
commit e6055e0f11
1 changed files with 9 additions and 11 deletions

View File

@ -280,19 +280,17 @@ function attemptSetEstimatedReleaseDate(fileEntry) {
} }
// a simple log proxy for when we call from oputil.js // a simple log proxy for when we call from oputil.js
const logDebug = (obj, msg) => { const maybeLog = (obj, msg, level) => {
if(Log) { if(Log) {
Log.debug(obj, msg); Log[level](obj, msg);
} else if ('error' === level) {
console.error(`${msg}: ${JSON.stringify(obj)}`); // eslint-disable-line no-console
} }
} };
const logError = (obj, msg) => { const logDebug = (obj, msg) => maybeLog(obj, msg, 'debug');
if(Log) { const logTrace = (obj, msg) => maybeLog(obj, msg, 'trace');
Log.error(obj, msg); const logError = (obj, msg) => maybeLog(obj, msg, 'error');
} else {
console.error(`${msg}: ${JSON.stringify(obj)}`);
}
}
function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) { function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) {
async.waterfall( async.waterfall(
@ -381,7 +379,7 @@ function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) {
// cleanup but don't wait // cleanup but don't wait
temptmp.cleanup( paths => { temptmp.cleanup( paths => {
// note: don't use client logger here - may not be avail // note: don't use client logger here - may not be avail
logDebug( { paths : paths, sessionId : temptmp.sessionId }, 'Cleaned up temporary files' ); logTrace( { paths : paths, sessionId : temptmp.sessionId }, 'Cleaned up temporary files' );
}); });
return callback(null); return callback(null);
}); });