1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/lib/logger.js

34 lines
732 B
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
2016-10-26 10:43:11 +02:00
2016-06-18 21:53:18 +02:00
const log4js = require('log4js');
let loggerProvider = getDefaultLogProvider();
2015-03-10 16:30:56 +01:00
module.exports = exports = function getLogger(name) {
return loggerProvider(name);
};
exports.setLoggerProvider = function setLoggerProvider(provider) {
loggerProvider = provider;
};
function getDefaultLogProvider() {
let level;
if (process.env.NODE_ENV === 'production') {
level = log4js.levels.ERROR;
} else if (process.env.NODE_ENV === 'test') {
level = log4js.levels.FATAL;
} else {
level = log4js.levels.DEBUG;
}
2015-03-10 16:30:56 +01:00
log4js.configure({
appenders: [{ type: 'console' }],
levels: {
'[all]': level,
},
});
return log4js.getLogger;
}