Created
October 28, 2016 12:05
-
-
Save mdesanti/542b6aedf5593ce1da53aed96f845839 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const winston = require('winston'), | |
moment = require('moment'), | |
config = require('../../config/config').config, | |
getNamespace = require('cls-hooked').getNamespace; | |
exports.logger = new winston.Logger({ | |
transports: [ | |
new winston.transports.Console({ | |
formatter: (options) => { | |
const ns = getNamespace('application'); | |
const requestId = ns ? ns.get('requestId') : ''; | |
const logLevel = options.level.toUpperCase(); | |
const time = moment(); | |
const message = options.message || ''; | |
return JSON.stringify({ | |
timestamp: time.toISOString(), | |
logLevel, | |
message, | |
requestId, | |
service: 'Microservice B' | |
}); | |
} | |
}) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment