Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Compatibility and fallback param support for logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tuleja committed Nov 19, 2018
1 parent a42555a commit 1dc4ecb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ const flatstr = require('flatstr');
const newConsole = require('console').Console;
const config = require('../config');

const defaultOutput = '/dev/stdout';

if (!Array.isArray(config.log.output)) {
if (typeof config.log.output === 'string') {
config.log.output = [config.log.output];
} else if (typeof config.log.file === 'string') {
config.log.output = [config.log.file];
} else {
config.log.output = [defaultOutput];
}
}

const logOutputs = config.log.output.map((outputPath) => {
const fileOutput = fs.createWriteStream(outputPath, { flags: 'a' });
return new newConsole(fileOutput, fileOutput);
Expand Down

0 comments on commit 1dc4ecb

Please sign in to comment.