From 4f850d5e9e86fa1aacd77a29d177ee9667083eff Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Fri, 28 Nov 2014 09:37:44 -0800 Subject: [PATCH] Support passing config to Logger#setup again --- lib/logger.js | 8 +++++++- spec/lib/logger.spec.js | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/logger.js b/lib/logger.js index cb8e2bb..373e0e7 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -28,7 +28,13 @@ var Logger = module.exports = {}; // or above // // Returns the new logger instance -Logger.setup = function setup() { +Logger.setup = function setup(opts) { + var Cylon = require('./cylon'); + + if (typeof opts === 'object') { + Cylon.config({ logging: opts }); + } + var logger = Config.logging.logger, level = Config.logging.level || "info"; diff --git a/spec/lib/logger.spec.js b/spec/lib/logger.spec.js index 27b90b6..fc7e53c 100644 --- a/spec/lib/logger.spec.js +++ b/spec/lib/logger.spec.js @@ -36,6 +36,15 @@ describe('Logger', function() { expect(Logger.toString()).to.be.eql("custom"); }); }); + + context("with a custom logger, provided directly", function() { + it("uses the custom logger", function() { + var logger = { toString: function() { return "custom"; } }; + Logger.setup({ logger: logger }); + expect(Logger.toString()).to.be.eql("custom"); + expect(Config.logging.logger).to.be.eql(logger); + }); + }); }); describe("proxies", function() {