From 44bf7ce5bb58580822dde1ba7d2f51467849fefe Mon Sep 17 00:00:00 2001 From: peteriman Date: Sat, 1 Jan 2022 00:29:25 +0800 Subject: [PATCH] Improved code readability for shutdown() function --- lib/log4js.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/log4js.js b/lib/log4js.js index 36cd489..b399816 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -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; @@ -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;