Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logger): move logger config to config file
add missing file
- Loading branch information
Showing
3 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
import winston from 'winston'; | ||
import config from '../../config'; | ||
import buildLoggerConfig from 'helpers/build-logger-config'; | ||
|
||
export default new winston.Logger({ | ||
transports: [ | ||
new winston.transports.Console({ | ||
level: 'debug', | ||
handleExceptions: true, | ||
json: false, | ||
colorize: true | ||
}) | ||
], | ||
exitOnError: false | ||
}); | ||
export default new winston.Logger(buildLoggerConfig(config.logger)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import winston from 'winston'; | ||
import {forEach, isFunction, clone} from 'lodash'; | ||
|
||
export default function buildLoggerConfig (config) { | ||
const loggerConfig = clone(config); | ||
loggerConfig.transports = []; | ||
forEach(config.transports, (transport, key) => { | ||
if (isFunction(winston.transports[key])) { | ||
loggerConfig.transports.push(new winston.transports[key](transport)); | ||
} | ||
}); | ||
return loggerConfig; | ||
} |