Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function initLogger(options) {
var customLoggingAppender = options['customServiceLogger'];
if ( customLoggingAppender ) {
// clear the default appender(s)
log4js.clearAppenders();
//
log4js.addAppender(customLoggingAppender, 'jive-sdk');
}
var logfile = options['logFile'] || options['logfile'];
var logLevel = process.env['jive_logging_level'] || options['logLevel'] || options['loglevel'] || 'INFO';
logLevel = logLevel.toUpperCase();
if (logfile) {
if (logfile.indexOf('logs/') === 0) {
if (!fs.existsSync('logs')) {
jive.logger.warn('logs subdirectory does not exist. Creating directory now.');
fs.mkdirSync('logs');
}
}
var logFileSize = options['logFileSize'] || undefined;
var logFileNumBackups = options['logFileNumBackups'] || undefined;
var settings = require('./settings'),
UrlProvider = require('./urlprovider-mongo').UrlProvider,
// UserProvider = require('./urlprovider-memory').UserProvider,
sys = require('sys'),
template = require('./template/template'),
loader = require('./template/loader'),
admin = require('./admin');
loader.set_path(settings.template_path);
/*
* LOGGING SUPPORT
*/
var log4js = require('log4js');
log4js.addAppender(log4js.consoleAppender(), 'app');
log4js.addAppender(log4js.consoleAppender(), 'resolved');
log4js.addAppender(log4js.consoleAppender(), 'defer_queue');
app_log = log4js.getLogger('app');
app_log.setLevel('TRACE');
resolved_log = log4js.getLogger('resolved');
resolved_log.setLevel('TRACE');
defer_log = log4js.getLogger('defer_queue');
defer_log.setLevel('TRACE');
// error handling
function handleError(error, res) {
app_log.error(error.message);
app_log.debug(JSON.stringify(error));
// return thresholded appender
return log4js.appenders.logLevelFilter(level, appender);
}
//
// clear default loggers
//
log4js.clearAppenders();
//
// configure console logger for non-production environment only
//
if ('production' !== N.runtime.env) {
log4js.addAppender(log4js.appenders.console());
}
//
// leave only loggers (with appenders) configs, removing keywords
//
delete config.options;
//
// configure logger categories and appenders
//
_.each(config, function (loggerConfig, name) {
_.each(loggerConfig, function (appenderConfig) {
var filename, appender;
before(function(done) {
var config = { esclient: mockElasticsearchClient, buffersize: 1 };
log4js.clearAppenders();
log4js.addAppender(log4jsElasticSearch.configure(config, null, done), 'unittest');
});
it("Must have created the template", function() {
before(function(done) {
var config = {
typeName: 'log4js',
buffersize: 1,
url: process.env.ES_URL,
layout: {
type: 'logstash'
}
};
log4js.clearAppenders();
log4js.addAppender(log4jsElasticSearch.configure(config, null, done), 'unittest');
});
function getLogger(dir){
log4js.loadAppender('file');
log4js.appenders['TASK'] = [];
var appender = log4js.appenders.file(dir + "/tast.log");
if(log4js.hasLogger("TASK")){
log4js.getLogger('TASK').removeAllListeners();
}
log4js.addAppender(appender,'TASK');
return log4js.getLogger('TASK');
}
const logFile = log4js.appenders.file(
path.join(__dirname, conf.logger.relativePath)
);
log4js.addLogger = name => {
if (!set.has(name)) {
set.add(name);
log4js.addAppender(logFile, name);
}
return log4js.getLogger(name);
};
const signupFile = log4js.appenders.file(
path.join(__dirname, '/../logs/signuplog.log')
);
log4js.addAppender(signupFile, 'signup');