diff --git a/lib/winston/container.js b/lib/winston/container.js index 6822798d9..e93f1692f 100644 --- a/lib/winston/container.js +++ b/lib/winston/container.js @@ -7,7 +7,8 @@ */ var common = require('./common'), - winston = require('../winston'); + winston = require('../winston'), + extend = require('util')._extend; // // ### function Container (options) @@ -36,9 +37,19 @@ var Container = exports.Container = function (options) { // an instance does not exist, one is created. // Container.prototype.get = Container.prototype.add = function (id, options) { + var existing; if (!this.loggers[id]) { - options = common.clone(options || this.options || this.default); - options.transports = options.transports || this.options.transports || []; + // + // Remark: Simple shallow clone for configuration options in case we pass in + // instantiated protoypal objects + // + options = extend({}, options || this.options || this.default); + existing = options.transports || this.options.transports; + // + // Remark: Make sure if we have an array of transports we slice it to make copies + // of those references. + // + options.transports = existing ? existing.slice() : []; if (options.transports.length === 0 && (!options || !options['console'])) { options.transports.push(this.default.transports[0]);