@carlosbajo/roket-micro
Version:
framework para microservicios con google/pubsub
22 lines (19 loc) • 754 B
JavaScript
const winston = require('winston');
const transport = require('@google-cloud/logging-winston');
const transports = { transports: [], rewriters: [], filters: [] };
const response = (app, nameOfKey) => {
if (nameOfKey) {
const opt = (process.env.GOOGLE_SERVICE) ? { resource: { type: 'service_account', labels: { email_id: app.config.default[nameOfKey].client_email } } } : { resource: 'global' }; // TODO get the correct value of config
winston.add(transport, opt);
} else {
winston.add(transport);
}
transports.transports.push(new winston.transports.Console({
label: 'koa2-logger',
timestamp: true,
handleExceptions: true,
humanReadableUnhandledException: true
}));
return winston;
};
module.exports = response;