this.manual_config_file = manual_config_file;
}
} catch (e) {
- //console.log('An error occured parsing the config file ' + manual_config_file + ': ' + e.message);
winston.error('An error occured parsing the config file %s: %s', manual_config_file, e.message);
process.exit(1);
}
} else {
- //console.log('Could not find config file ' + manual_config_file);
winston.error('Could not find config file %s', manual_config_file);
process.exit(1);
}
case 'ENOENT': // No file/dir
break;
default:
- //console.log('An error occured parsing the config file ' + config_dirs[i] + config_filename + ': ' + e.message);
winston.warn('An error occured parsing the config file %s%s: %s', config_dirs[i], config_filename, e.message);
return false;
}
// Get the current config. Optionally for a different environment than currently set
Config.prototype.get = function (specific_environment) {
specific_environment = specific_environment || environment;
-
+
return loaded_config[specific_environment] || {};
};
events.EventEmitter.call(this);
this.client = client;
this.save_state = save_state || false;
-
+
this.irc_connections = [];
this.next_connection = 0;
-
+
this.client.on('dispose', function () {
if (!that.save_state) {
_.each(that.irc_connections, function (irc_connection, i, cons) {
cons[i] = null;
}
});
-
+
that.dispose();
}
});
});
con.on('error', function IrcConnectionError(err) {
- //console.log('irc_connection error (' + hostname + '):', err);
- winston.warn('irc_connection error (%s): %s', hostname, err);
+ winston.warn('irc_connection error (%s):', hostname, err);
return callback(err.message);
});
log_file_name = __dirname + '/../' + log_file_name;
}
- winston.add(winston.transports.File, { filename: log_file_name, json: false});
+ winston.add(winston.transports.File, {
+ filename: log_file_name,
+ json: false,
+ timestamp: function() {
+ var year, month, day, time_string,
+ d = new Date();
+
+ year = String(d.getFullYear());
+ month = String(d.getMonth() + 1);
+ if (month.length === 1) {
+ month = "0" + month;
+ }
+
+ day = String(d.getDate());
+ if (day.length === 1) {
+ day = "0" + day;
+ }
+
+ // Take the time from the existing toTimeString() format
+ time_string = (new Date()).toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
+
+ return year + "-" + month + "-" + day + ' ' + time_string;
+ }
+ });
+
winston.remove(winston.transports.Console);
})();
}
// Make sure we have a valid config file and at least 1 server
if (!global.config || Object.keys(global.config).length === 0) {
- //console.log('Couldn\'t find a valid config.js file (Did you copy the config.example.js file yet?)');
winston.error('Couldn\'t find a valid config.js file (Did you copy the config.example.js file yet?)');
process.exit(1);
}
if ((!global.config.servers) || (global.config.servers.length < 1)) {
- //console.log('No servers defined in config file');
winston.error('No servers defined in config file');
process.exit(2);
}
if (global.config.module_dir) {
(global.config.modules || []).forEach(function (module_name) {
if (modules.load(module_name)) {
- //console.log('Module ' + module_name + ' loaded successfuly');
winston.info('Module %s loaded successfully', module_name);
} else {
- //console.log('Module ' + module_name + ' failed to load');
winston.warn('Module %s failed to load', module_name);
}
});
serv.listen(server.port, server.address, server);
serv.on('listening', function() {
- //console.log('Kiwi proxy listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without'));
winston.info('Kiwi proxy listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without'));
});
});
wl.on('listening', function () {
- //console.log('Listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without'));
winston.info('Listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without'));
webListenerRunning();
});
wl.on('error', function (err) {
- //console.log('Error listening on %s:%s: %s', server.address, server.port, err.code);
winston.info('Error listening on %s:%s: %s', server.address, server.port, err.code);
// TODO: This should probably be refactored. ^JA
webListenerRunning();
// Make sure Kiwi doesn't simply quit on an exception
process.on('uncaughtException', function (e) {
- //console.log('[Uncaught exception] ' + e);
- //console.log(e.stack);
winston.error('[Uncaught exception] %s', e, {stack: e.stack});
});
process.on('SIGUSR1', function() {
if (config.loadConfig()) {
- //console.log('New config file loaded');
winston.info('New config file loaded');
} else {
- //console.log("No new config file was loaded");
winston.info('No new config file was loaded');
}
});
process.on('SIGUSR2', function() {
- //console.log('Connected clients: ' + _.size(global.clients.clients).toString());
- //console.log('Num. remote hosts: ' + _.size(global.clients.addresses).toString());
winston.info('Connected clients: %s', _.size(global.clients.clients));
winston.info('Num. remote hosts: %s', _.size(global.clients.addresses));
});