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)); }); };