From fc3ae676f1bc9a4e196a81181c455fc19a37b4f3 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Fri, 29 Jan 2016 14:50:51 +0000 Subject: [PATCH] fix shutdown callbacks not being called --- lib/appenders/dateFile.js | 3 +++ lib/appenders/file.js | 3 +++ lib/log4js.js | 3 +++ 3 files changed, 9 insertions(+) diff --git a/lib/appenders/dateFile.js b/lib/appenders/dateFile.js index 411bc5b..7eaeef4 100644 --- a/lib/appenders/dateFile.js +++ b/lib/appenders/dateFile.js @@ -65,6 +65,9 @@ function shutdown(cb) { cb(error); } }; + if (!openFiles.length) { + return cb(); + } openFiles.forEach(function(file) { if (!file.write(eol, "utf-8")) { file.once('drain', function() { diff --git a/lib/appenders/file.js b/lib/appenders/file.js index 8ad530e..5b2959e 100644 --- a/lib/appenders/file.js +++ b/lib/appenders/file.js @@ -93,6 +93,9 @@ function shutdown(cb) { cb(error); } }; + if (!openFiles.length) { + return cb(); + } openFiles.forEach(function(file) { if (!file.write(eol, "utf-8")) { file.once('drain', function() { diff --git a/lib/log4js.js b/lib/log4js.js index 68ca51b..4e3a4da 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -444,6 +444,9 @@ function shutdown(cb) { shutdownFcts.push(appenderShutdowns[category]); } } + if (!shutdownFcts.length) { + return cb(); + } shutdownFcts.forEach(function(shutdownFct) { shutdownFct(complete); }); }