Skip to content

Commit

Permalink
fix: fix dynamic requires
Browse files Browse the repository at this point in the history
  • Loading branch information
stambata committed Oct 19, 2016
1 parent 7f35691 commit 33228c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ var lib = {
**/
function Logger(options) {
options.lib = lib;
this.init(require('./modules/' + (options.type || 'winston'))(options));
if (options.type === 'winston') {
this.init(require('./modules/winston')(options));
} else { // require bunyan by default
this.init(require('./modules/bunyan')(options));
}
}

Logger.prototype.init = function LoggerInit(logger) {
Expand Down
2 changes: 1 addition & 1 deletion modules/bunyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function fixStreams(streams, workDir) {
stream.stream = process.stdout;
}
} else if (typeof stream.stream === 'string') {
createStream = require(stream.stream);
createStream = serverRequire(stream.stream);
stream.streamConfig.workDir = workDir;
stream.stream = createStream(stream.streamConfig);
delete stream.streamConfig;
Expand Down
6 changes: 0 additions & 6 deletions modules/winston.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ function Winston(options) {
});
transports = fixStreams(options.streams);
}
var dependencies = options.dependencies;
if (dependencies && dependencies.length) {
dependencies.forEach(function(element) {
require(element); // try catch maybe
});
}

return function createLogger(params) {
var log = container.add(params.name || options.name, transports);
Expand Down

0 comments on commit 33228c1

Please sign in to comment.