From ecd9647a2ec5e15f05e7368c038cf6eba72c0224 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 23 Apr 2019 13:25:03 +0200 Subject: [PATCH] add shutdown command for the logstore --- lib/log.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/log.js b/lib/log.js index 31c98c4f5..9ea5562e1 100644 --- a/lib/log.js +++ b/lib/log.js @@ -52,6 +52,9 @@ var createLogType = function (ctx, type) { return noop; } return function (tag, info) { + if (ctx.shutdown) { + throw new Error("Logger has been shut down!"); + } var time = new Date().toISOString(); var content; try { @@ -98,7 +101,13 @@ Logger.create = function (config, cb) { filePath: config.logPath, }, function (store) { ctx.store = store; - cb(Object.freeze(createMethods(ctx))); + var logger = createMethods(ctx); + logger.shutdown = function () { + delete ctx.store; + ctx.shutdown = true; + store.shutdown(); + }; + cb(Object.freeze(logger)); }); };