Skip to content

Commit

Permalink
Improved code readability for shutdown() function
Browse files Browse the repository at this point in the history
  • Loading branch information
lamweili committed Jan 4, 2022
1 parent 1e066b9 commit 44bf7ce
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/log4js.js
Expand Up @@ -104,9 +104,13 @@ function shutdown(cb) {
(accum, next) => (next.shutdown ? accum + 1 : accum),
0
);
if (shutdownFunctions === 0) {
debug("No appenders with shutdown functions found.");
return cb !== undefined && cb();
}

let completed = 0;
let error;

debug(`Found ${shutdownFunctions} appenders with shutdown functions.`);
function complete(err) {
error = error || err;
Expand All @@ -119,12 +123,6 @@ function shutdown(cb) {
}
}
}

if (shutdownFunctions === 0) {
debug("No appenders with shutdown functions found.");
return cb !== undefined && cb();
}

appendersToCheck.filter(a => a.shutdown).forEach(a => a.shutdown(complete));

return null;
Expand Down

0 comments on commit 44bf7ce

Please sign in to comment.