Support passing config to Logger#setup again
This commit is contained in:
parent
83153664f5
commit
4f850d5e9e
|
@ -28,7 +28,13 @@ var Logger = module.exports = {};
|
||||||
// or above
|
// or above
|
||||||
//
|
//
|
||||||
// Returns the new logger instance
|
// 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,
|
var logger = Config.logging.logger,
|
||||||
level = Config.logging.level || "info";
|
level = Config.logging.level || "info";
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,15 @@ describe('Logger', function() {
|
||||||
expect(Logger.toString()).to.be.eql("custom");
|
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() {
|
describe("proxies", function() {
|
||||||
|
|
Loading…
Reference in New Issue