Example #1
0
var Highway = function (settings) {
	var ObjectId = require('mongojs')
		.ObjectId;
	var _ = require('underscore');
	var express = require('express');
	var Email = require('./src/email.js');
	var DB = require('./src/crud.js');
	var reststop = require('./src/rest-stop.js');
	var SocketServer = require('./src/socket.js');
	var Auth = require('./src/auth.js');
	var winston = require('winston');

	var defaults = {
		io: false,
		http: false,
		uri: false,
		database: false,
		auth: [],
		email: {},
		log: false
	};

	if (!settings) {
		throw new Error('No settings provided');
	}

	// logger crap
	if (settings && settings.log) {
		winston.add(winston.transports.File, {
			filename: '/var/log/highway.log',
			json: false
		});
		winston.remove(winston.transports.Console);
	}
	var self = this;
	self.settings = _.defaults(settings || {}, defaults);
	self.io = self.settings.io;
	self.socketservers = self.sockets = {};
	self.mailer = new Email(self.settings.email);
	self.logger = self.settings.log ? winston.log : function () {};



	// get the IP address of the device this is running on
	var os = require('os');
	var ifaces = os.networkInterfaces();

	Object.keys(ifaces).forEach(function (ifname) {
		var alias = 0;

		ifaces[ifname].forEach(function (iface) {
			if ('IPv4' !== iface.family || iface.internal !== false) {
				// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
				return;
			}

			if (alias >= 1) {
				// this single interface has multiple ipv4 addresses
				self.ip = iface.address;
			} else {
				// this interface has only one ipv4 adress
				self.ip = iface.address;
			}
			++alias;
		});
	});


	function PrepareHTTP() {
		if (!self.settings.http)
			return;

		var bodyParser = require('body-parser');
		var cookieParser = require('cookie-parser');

		self.settings.http.use(cookieParser());
		self.settings.http.use(bodyParser.urlencoded({
			extended: true
		}));
		self.settings.http.use(bodyParser.json());
		return true;
	}


	return new Promise(function (success, failure) {
		PrepareHTTP();
		var db = new DB(settings.uri + '/' + settings.database, settings.hooks, self);
		db.connect()
			.then(function (d) {
				self.db = d;
				var auth = new Auth(self)
					.then(function (s) {
						collections = _.clone(self.db.collections);
						while ((collection = collections.pop()) !== undefined) {
							if (collection.trim() !== '' && collection != 'system.indexes') {
								self.sockets[collection] = self.io.of('/' + settings.database + '/' + collection);
								self.socketservers[collection] = new SocketServer(self.io, collection, self.db); //SetUpSockets( collection );
								if (self.settings.http) {
									self.settings.http.use('/' +
										settings.database + '/' + collection, new reststop(collection, self.db, self.io.of('/' + settings.database + '/' + collection)));
								}
							}
						}

						if (typeof self.settings.onComplete == 'function') {
							self.settings.onComplete(self, _, ObjectId);
						}

						success(self);
					});
			}, function (err) {
				failure(err);
				console.error('Unable to connect to database: ', err);
			});
	});
};
Example #2
0
'use strict';

var winston = require('winston');
var moment = require('moment');
var pushover = require('winston-pushover').Pushover;
var papertrail = require('winston-papertrail').Papertrail;
var stdout = winston.transports.Console;

winston.remove(stdout);

add(stdout, 'CONSOLE_ENABLED', {
    timestamp: timestamps,
    colorize: true,
    level: conf('CONSOLE_LEVEL')
});

add(pushover, 'PUSHOVER_ENABLED', {
    level: conf('PUSHOVER_LEVEL'),
    userKey: conf('PUSHOVER_USER_KEY'),
    token: conf('PUSHOVER_API_TOKEN')
});

add(papertrail, 'PAPERTRAIL_ENABLED', {
    host: conf('PAPERTRAIL_HOST'),
    port: conf('PAPERTRAIL_PORT'),
    level: conf('PAPERTRAIL_LEVEL')
});

function add (transport, enabled, options) {
    var on = conf(enabled);
    if (on) { winston.add(transport, options); }
Example #3
0
function errorLog(message) {
    logging.error(message);
}

swig.init({
    filters: require('./colors.js'),
    autoescape: false,
    root: __dirname
});

logging.add(logging.transports.File, {
    filename: process.env.HOME + '/logs/lolrrit-wm.log',
    json: false
});
logging.remove(logging.transports.Console);

var allChannels = _.keys(config.channels);

if(allChannels.indexOf(config['default-channel']) === -1) {
    allChannels.push(config['default-channel']);
}

if(typeof config['firehose-channel'] !== "undefined" && allChannels.indexOf(config['firehose-channel']) === -1) {
    allChannels.push(config['firehose-channel']);
}

logging.info("joining channels", allChannels);

function channelsForRepo(repo, branch) {
    var channels = [];
Example #4
0
'use strict';

require('coffee-script/register');
var path             = require('path');
var util             = require('util');
var gutil            = require('gulp-util');
var through          = require('through2');
var winston          = require('winston');
var TokenizerFactory = require('jscpd/lib/tokenizer/TokenizerFactory');
var Mapper           = require('jscpd/lib/map').Map;
var Strategy         = require('jscpd/lib/strategy').Strategy;
var Report           = require('jscpd/lib/report').Report;

var optionsPreprocessor = require('jscpd/lib/preprocessors/options');

winston.remove(winston.transports.Console); // Silent jscpd logging messages

module.exports = function(opts) {
  opts = util._extend({
    'min-lines' : 5,
    'min-tokens': 70,
    reporter    : 'xml',
    languages   : Object.keys(TokenizerFactory.prototype.LANGUAGES),
    output      : null,
    path        : null,
    verbose     : false,
    debug       : false,
    silent      : false,
    failOnError : true,
    'xsl-href'  : null
  }, opts);
Example #5
0
exports.initLog = function(name, logLevel_) {
  winston.add(winston.transports.File, { filename: name, maxsize: 5000000, maxFiles: 10});
  winston.remove(winston.transports.Console);
  logLevel = logLevel_;
}
Example #6
0
File: app.js Project: krtong/NodeBB
(function () {
	"use strict";

	// Configuration setup
	var nconf = require('nconf');
	nconf.argv().env();

	var fs = require('fs'),
		async = require('async'),
		semver = require('semver'),
		winston = require('winston'),
		path = require('path'),
		pkg = require('./package.json'),
		utils = require('./public/src/utils.js'),
		meta;

	// Runtime environment
	global.env = process.env.NODE_ENV || 'production';

	winston.remove(winston.transports.Console);
	winston.add(winston.transports.Console, {
		colorize: true
	});

	winston.add(winston.transports.File, {
		filename: 'error.log',
		level: 'error'
	});

	// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
	winston.err = function (err) {
		winston.error(err.stack);
	};

	require('child_process').exec('/usr/bin/which convert', function(err, stdout, stderr) {
		if(err || !stdout) {
			winston.warn('Couldn\'t find convert. Did you install imagemagick?');
		}
	});

	// Log GNU copyright info along with server info
	winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.');
	winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
	winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
	winston.info('');


	if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
		// Load server-side configs
		nconf.file({
			file: __dirname + '/config.json'
		});
		meta = require('./src/meta');

		nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + path.sep);
		nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep));
		nconf.set('base_dir', __dirname);

		winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using ' + nconf.get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.');
		winston.info('NodeBB instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address')));

		if (process.env.NODE_ENV === 'development') {
			winston.info('Base Configuration OK.');
		}

		if (!semver.satisfies(require('./node_modules/nodebb-theme-cerulean/package.json').version, pkg.dependencies['nodebb-theme-cerulean'])) {
			winston.error('nodebb-theme-cerulean is out of date - please run npm install.');
		}

		if (!semver.satisfies(require('./node_modules/nodebb-theme-vanilla/package.json').version, pkg.dependencies['nodebb-theme-vanilla'])) {
			winston.error('nodebb-theme-vanilla is out of date - please run npm install.');
		}

		require('./src/database').init(function(err) {
			meta.configs.init(function () {

				var templates = require('./public/src/templates'),
					translator = require('./public/src/translator'),
					webserver = require('./src/webserver'),
					sockets = require('./src/socket.io'),
					plugins = require('./src/plugins'),
					notifications = require('./src/notifications'),
					upgrade = require('./src/upgrade');

				templates.setGlobal('relative_path', nconf.get('relative_path'));

				upgrade.check(function(schema_ok) {
					if (schema_ok || nconf.get('check-schema') === false) {

						sockets.init();

						plugins.init();
						global.templates = {};
						global.translator = translator;

						translator.loadServer();

						var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;


						utils.walk(path.join(__dirname, 'public/templates'), function (err, tplsToLoad) {
							templates.init(tplsToLoad, customTemplates);
						});

						plugins.ready(function() {
							templates.ready(webserver.init);
						});

						notifications.init();
					} else {
						winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
						winston.warn('    node app --upgrade');
						winston.warn('To ignore this error (not recommended):');
						winston.warn('    node app --no-check-schema')
						process.exit();
					}
				});
			});
		});
	} else if (nconf.get('setup') || nconf.get('install') || !fs.existsSync(__dirname + '/config.json')) {
		// New install, ask setup questions
		if (nconf.get('setup')) {
			winston.info('NodeBB Setup Triggered via Command Line');
		} else {
			winston.warn('Configuration not found, starting NodeBB setup');
		}

		nconf.file({
			file: __dirname + '/config.json'
		});

		var templates = require('./public/src/templates'),
			install = require('./src/install');

		winston.info('Welcome to NodeBB!');
		winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');
		winston.info('Press enter to accept the default setting (shown in brackets).');

		install.setup(function (err) {
			if (err) {
				winston.error('There was a problem completing NodeBB setup: ', err.message);
			} else {
				winston.info('NodeBB Setup Completed. Run \'node app\' to manually start your NodeBB server.');
			}

			process.exit();
		});

	} else if (nconf.get('upgrade')) {
		nconf.file({
			file: __dirname + '/config.json'
		});
		require('./src/database').init(function(err) {
			meta = require('./src/meta.js');

			meta.configs.init(function () {
				require('./src/upgrade').upgrade();
			});
		});
	} else/* if (nconf.get('help') */{
		winston.info('Usage: node app [options] [arguments]');
		winston.info('       [NODE_ENV=development | NODE_ENV=production] node app [--start] [arguments]');
		winston.info('');
		winston.info('Options:');
		winston.info('  --help              displays this usage information');
		winston.info('  --setup             configure your environment and setup NodeBB');
		winston.info('  --upgrade           upgrade NodeBB, first read: github.com/designcreateplay/NodeBB/wiki/Upgrading-NodeBB');
		winston.info('  --start             manually start NodeBB (default when no options are given)');
	};
}());
Example #7
0
module.exports = function (client) {
  'use strict';

  var fs = require('fs');
  var path = require('path');
  var winston = require('winston');
  var config = require('./config');

  try {
    winston.remove(winston.transports.Console);
  } catch(e) { }
  
  var hasDebuggingOption;
  if (client.isCommandLine()) {
    // check if global --log is on
    var argv = client.program.normalize(process.argv);
    hasDebuggingOption = argv.indexOf('-d') > -1 || argv.indexOf('--verbose') > -1; // Need this early
  }

  // var logger = new (winston.Logger)({
  //   exitOnError: false
  // });
  // 
  // file-based logging, set up in client
  var logFileLevel;
  if (config.get('mm_log_level')) {
    logFileLevel = config.get('mm_log_level').toLowerCase();
  } else {
    logFileLevel = 'info'; 
  }

  // if --verbose flag, add console logging
  if (hasDebuggingOption || client.verbose) {
    winston.cli();
    winston.add(winston.transports.Console, {
      level: logFileLevel,
      exitOnError: false,
      prettyPrint: true,
      colorize: true
    });
  }

  // place logs in mm_log_location if it exists
  if (fs.existsSync(config.get('mm_log_location'))) {
    try {
      winston.add(winston.transports.File, { 
        filename: path.join(config.get('mm_log_location'), 'mavensmate.log'),
        level: logFileLevel,
        json: false
      });
    } catch(e) {
      if (e.message.indexOf('Transport already attached') === -1) {
        throw e;
      }
    }
  }

  if (hasDebuggingOption) {
    winston.debug('Debug logging is on');
  }

  return winston;
};
Example #8
0
(function() {
	"use strict";

	var nconf = require('nconf'),
		fs = require('fs'),
		winston = require('winston'),
		path = require('path'),
		pkg = require('./package.json'),
		utils = require('./public/src/utils.js'),
		meta;

	nconf.argv().env();

	// Runtime environment
	global.env = process.env.NODE_ENV || 'production';

	winston.remove(winston.transports.Console);
	winston.add(winston.transports.Console, {
		colorize: true
	});

	winston.add(winston.transports.File, {
		filename: 'error.log',
		level: 'error'
	});

	// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
	winston.err = function (err) {
		winston.error(err.stack);
	};


	if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
		// Load server-side configs
		nconf.file({
			file: __dirname + '/config.json'
		});
		meta = require('./src/meta');

		nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
		nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep));
		nconf.set('base_dir', __dirname);

		winston.info('Time: ' + new Date());
		winston.info('Initializing Node Application v' + pkg.version + ', on port ' + nconf.get('port') + ', using ' + nconf.get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.');
		winston.info('Node Application instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address')));

		if (process.env.NODE_ENV === 'development') {
			winston.info('Base Configuration OK.');
		}

		require('./src/database').init(function(err) {
			meta.configs.init(function () {

				var templates = require('./public/src/templates'),
					translator = require('./public/src/translator'),
					webserver = require('./src/webserver'),
					plugins = require('./src/plugins');

				templates.setGlobal('relative_path', nconf.get('relative_path'));

				
				//upgrade.check(function(schema_ok) {
				//	if (schema_ok || nconf.get('check-schema') === false) {
						plugins.init();

						translator.loadServer();

						var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;

						utils.walk(path.join(__dirname, 'public/templates'), function (err, tplsToLoad) {
							templates.init(tplsToLoad, customTemplates);
						});

						plugins.ready(function() {
							templates.ready(webserver.init);
						});

						//notifications.init();
				/*	} else {
						winston.warn('Your schema is out-of-date. Please run the following command to bring your dataset up to spec:');
						winston.warn('    node app --upgrade');
						winston.warn('To ignore this error (not recommended):');
						winston.warn('    node app --no-check-schema')
						process.exit();
					}
				}); */
			});
		});
	} else if (nconf.get('setup') || nconf.get('install') || !fs.existsSync(__dirname + '/config.json')) {
		// New install, ask setup questions
		if (nconf.get('setup')) {
			winston.info('Setup Triggered via Command Line');
		} else {
			winston.warn('Configuration not found, starting setup');
		}
		
		nconf.file({
			file: __dirname + '/config.json'
		});

		var templates = require('./public/src/templates'),
			install = require('./src/install');

		winston.info('Welcome!');
		winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');
		winston.info('Press enter to accept the default setting (shown in brackets).');

		install.setup(function (err) {
			if (err) {
				winston.error('There was a problem completing setup: ', err.message);
			} else {
				winston.info('Setup Completed. Run \'./nodebb start\' to manually start your server.');
			}

			process.exit();
		});
	} else if (nconf.get('upgrade')) {

	} else {
		winston.info('Usage: node app [options] [arguments]');
		winston.info('       [NODE_ENV=development | NODE_ENV=production] node app [--start] [arguments]');
		winston.info('');
		winston.info('Options:');
		winston.info('  --help              displays this usage information');
		winston.info('  --setup             configure your environment and setup');
		winston.info('  --upgrade           upgrade');
		winston.info('  --start             manually start NodeBB (default when no options are given)');		
	}

})();
	var __construct = function() {

		winston.remove(winston.transports.Console);
		winston.add(winston.transports.File, {filename: 'test.log', handleExceptions: true, level: 'debug'});
		winston.add(winston.transports.Console, {handleExceptions: true, level: 'error'});

		winston.log('info', 'Initialising jasmine tests');

		browser.getCapabilities().then(function(currentCapabilities) {
			if (currentCapabilities.caps_.browserName == 'internet explorer') {
				that.isIE = true;
			}
			else that.isIE = false;

			if (currentCapabilities.caps_.browserName == 'firefox') {
				that.isFirefox = true;
			}
			else that.isFirefox = false;
			


			that.currentCapabilities = currentCapabilities;
			that.browser = currentCapabilities.caps_.browserName;
			that.browserVersion = currentCapabilities.caps_.version;
			
			//iPhone sometimes doesn't report version 
			if (!that.browser) {
				console.log("browser undefined");
				that.browser = currentCapabilities.caps_.desired.platformName;
			}
			if (!that.browserVersion) {
				console.log("browser version undefined");
				if (currentCapabilities.caps_.hasOwnProperty('desired')) {
					that.browserVersion = currentCapabilities.caps_.desired.platformVersion;
					that.browser = currentCapabilities.caps_.desired.platformName;
				}
				else if (currentCapabilities.caps_.hasOwnProperty('platformVersion')) {
					that.browserVersion = currentCapabilities.caps_.platformVersion;
				}

				
			}
			
			winston.log('info', currentCapabilities.caps_);
			winston.log('info', that.deviceOrientation);
			winston.log('info', currentCapabilities);
			console.log(currentCapabilities);
			console.log(currentCapabilities.caps_);

			that.sessionID = currentCapabilities.caps_["webdriver.remote.sessionid"];
			//Append browser and version to every filepath
			for (var key in that.filePaths) {
				winston.log("info", "Initialising file paths with browser & version");
				if (that.filePaths[key].charAt(0) == '/') {
					that.filePaths[key] = that.filePaths[key] + that.browser + that.browserVersion + '.png';
				}
			}

			that.instanceString = that.browser + that.browserVersion + that.sessionID;

		});

		for (var key in that.elements) {
			that.elementFinder[key] = element(by.css(that.elements[key]));
		}

	}();
Example #10
0
before(function () {
  // Prevent winston from logging while testing
  //winston.level = 'debug';
  winston.remove(winston.transports.Console);
});
Example #11
0
 before(function () {
   winston.remove(winston.transports.Console);
   winston.add(winston.transports.Orchestrate, { apiKey: 'xxx', collection: 'test' });
 });
Example #12
0
module.exports = function () {
  winston.remove(winston.transports.Console);
  winston.add(winston.transports.Console, {colorize: true, json: false, timestamp: true });
  winston.info("Initialized Winston");
};
Example #13
0
app.configure('production', function() {
  winston.remove(winston.transports.Console);
});
Example #14
0
		onDrain:function(){
			logger.info("Job done.");
			logger.remove(godotTransport);
			client.close();
		},
var utils = require('./utils.js');
//yaml parse
var YAML =require('libyaml')

//parse arguments to get operating mode
var args = process.argv.splice(2);
if( args.length < 1 ){ args = ['development'] }
var op_mode = args[0]

//set up the logger
var w = require('winston');
//add file output in rails log dir
w.add( w.transports.File, { filename: '../log/'+op_mode+'-node.log' } );
//if production, stop logging to the console
if( op_mode=='production'){
	w.remove( w.transports.Console );
}

w.info('initializing switchB push server in '+op_mode+' mode')

//prepare a configured redis client
module.exports.start_redis = function(){

	//load yaml file for redis config
	var redis_config = YAML.readFileSync('../config/redis.yml')
	if( !redis_config ){
		throw('could not load redis.yml!!! stopping!!!')
	}
	redis_config = redis_config[0][op_mode]  
	if( redis_config === undefined ){
		throw('did not find redis config for '+open_mode)
Example #16
0
function Init(cb) {

    var options = { //According to satip specification (pag.43 update 8th jan 2015), this should be the default values for client queries.
        src: '1',
        ro: '0.35',
        mtype: 'qpsk',
        plts: 'off',
        serverPort: '554',
        Cseq: '1'
    };
    var loggerOptions = {
        colorize: true
    }

    logger.remove(logger.transports.Console);

    // Check if contains at least 3 important options to execute client
    if (process.argv.toString().match(/satips=/) && process.argv.toString().match(/cmd=/) && process.argv.toString().match(/dst=/)) {

        if (optionss.verbosity) { // Set logger levels
            if (optionss.verbosity == 0) {
                loggerOptions.level = 'info';
            } else if (optionss.verbosity == 1) {
                loggerOptions.level = 'verbose';
            } else if (optionss.verbosity == 2) {
                loggerOptions.level = 'debug';
            } else {
            }
            logger.add(logger.transports.Console, loggerOptions);
        } else {
            loggerOptions.level = 'info'
            logger.add(logger.transports.Console, loggerOptions);
        }
        if(optionss.logFile) {
            loggerOptions.filename = 'logFile.log'
            logger.add(logger.transports.File, loggerOptions);
        }

        options.logger = logger;
        options.logger.info("Init SAT>IP RTSP-Client test\n\n");

        process.argv.forEach(function (val) { // Parse all the arguments, also args in cmd string
            if (val !== undefined) {
                var arrayAux = val.split(/=/);

                switch (arrayAux[0]) {
                    case 'satips':
                        options.protocolType = 'satips';
                        var serverIp = arrayAux[1].split(/:/);
                        if (serverIp[0] !== undefined) {
                            options.externServer = serverIp[0];
                        }
                        else {
                            options.externServer = '127.0.0.1';
                        }
                        if (serverIp[1] !== undefined) {
                            options.serverPort = serverIp[1];
                        } else {
                            options.serverPort = 554;
                        }
                        break;
                    case 'dst': // Check destination IP & port, Also assign base port
                        var destinationIP = arrayAux[1].split(/:/);
                        if (destinationIP[0] !== undefined) {
                            options.destination = destinationIP[0];
                        } else {
                            options.logger.error('ERROR Missing destination\n');
                            process.exit();
                        }
                        if (destinationIP[1] !== undefined) {
                            options.clientports = destinationIP[1] + "-" + (parseInt(destinationIP[1]) + 1);
                            if (optionss.Port !== undefined) {
                                options.destinationPorts = optionss.Port + "-" + (parseInt(optionss.Port) + 1);
                            } else {
                                options.destinationPorts = (parseInt(destinationIP[1]) + 2) + "-" + (parseInt(destinationIP[1]) + 3);
                            }
                        }
                        break;

                    case 'cmd': //Parse 'cmd=' arguments and assign to var
                        if (val.split(/=/)[1].match(/\?/)) {
                            var comanda = val.slice(5).split(/&/);
                        } else {
                            var comanda = val.slice(4).split(/%/);
                        }
                        var comandaAux = VerEx().find(/&pids=[\d*,*]*/).replace(val.slice(4), "");
                        comandaAux = VerEx().find(/all/).replace(comandaAux, "");
                        comandaAux = VerEx().find(/&addpids=[\d*,*]*/).replace(comandaAux, "");
                        options.comanda = VerEx().find(/all/).replace(comandaAux, "");

                        comanda.forEach(function (val) {
                            var individual = val.split(/=/);

                            switch (individual[0]) {

                                case 'freq':
                                    options.freq = individual[1];
                                    break;
                                case 'fe':
                                    options.fe = individual[1];
                                    break;
                                case 'src':
                                    options.src = individual[1];
                                    break;
                                case 'pol':
                                    options.pol = individual[1];
                                    break;
                                case 'ro':
                                    options.ro = individual[1];
                                    break;
                                case 'msys':
                                    options.msys = individual[1];
                                    break;
                                case 'sr':
                                    options.sr = individual[1];
                                    break;
                                case 'fec':
                                    options.fec = individual[1];
                                    break;
                                case 'pids':
                                    options.pids = individual[1];
                                    break;
                                case 'addpids':
                                    options.pids = individual[1];
                                    break;
                                case 'mtype':
                                    options.mtype = individual[1];
                                    break;
                                case 'plts':
                                    options.plts = individual[1];
                                    break;

                                case 'bw':
                                    options.bw = individual[1];
                                    break;
                                case 'tmode':
                                    options.tmode = individual[1];
                                    break;
                                case 'gi':
                                    options.gi = individual[1];
                                    break;

                            }
                        });
                        break;
                }
            } else {
                options.logger.error("Wrong parameters!\n");
                process.exit();
            }
        });

        if (optionss.multicast) {
            options.multicast = true;
        } else {
            options.multicast = false;
        }
        options.port = optionss.port;
        if (optionss.Commands) {
            options.commands = true;
        } else {
            options.commands = false;
        }
        if(!options.commands){
            if(options.msys == 'dvbt') {
                options.logger.debug("Parameters Parsed: Freq=" + options.freq+" src="+options.src+" mtype="+options.mtype+" pids="+options.pids+" fe="+options.fe+" bw="+options.bw+" tmode="+options.tmode+" gi="+options.gi+"\n");
            }else if (options.msys === 'dvbs' || options.msys === 'dvbs'){
                options.logger.debug("Parameters Parsed: Freq=" + options.freq+" src="+options.src+" mtype="+options.mtype+" fe="+options.fe+" pids="+options.pids+" pol="+options.pol+" src="+options.src+" plts="+options.plts+" ro="+options.ro+" fec="+options.fec+"\n");
            }
        }
        cb(options);
    } else {
        options.printHelp();
        process.exit();
    }
}
Example #17
0
 'should just work': function () {
   winston.add(winston.transports.Syslog);
   winston.remove(winston.transports.Syslog);
   winston.add(winston.transports.Syslog);
   winston.remove(winston.transports.Syslog);
 }
Example #18
0
module.exports = function () {
  winston.remove(winston.transports.Console);
  winston.add(winston.transports.Console, {colorize: true, json: false});
};
Example #19
0
var config                  = require('./config');
var proxy_router            = require('./routes/proxy');
var stop_users_containers   = require('./local_modules/users-container').trigger_timeouts;


/**
 * Base setup
 **********************************************************************************************************************/

// Setup config
var port = config.app.port;

// Setup log config
log.level = config.log.level;
log.remove(log.transports.Console).add(log.transports.Console, { colorize: true });
log.add(log.transports.File, { filename: '/var/log/node/node-proxy.log' });

// Create express server
var app = express();

// Use morgan to print logs
app.use( morgan('combined', {stream: fs.createWriteStream('/var/log/node/access.log', {flags: 'a'})}) );
if ( app.get('env') === 'development' ) {
	app.use( morgan('dev') );
} else {
	app.use( morgan('combined') );
}

// Setup view engine
app.set('views', path.join(__dirname, 'views'));
Example #20
0
(function () {
	"use strict";

	// Configuration setup
	var nconf = require('nconf');
	nconf.argv().env();

	var fs = require('fs'),
		async = require('async'),
		winston = require('winston'),
		pkg = require('./package.json'),
		path = require('path'),
		meta;

	// Runtime environment
	global.env = process.env.NODE_ENV || 'production';

	winston.remove(winston.transports.Console);
	winston.add(winston.transports.Console, {
		colorize: true
	});

	winston.add(winston.transports.File, {
		filename: 'error.log',
		level: 'error'
	});

	// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
	winston.err = function (err) {
		winston.error(err.stack);
	};

	// Log GNU copyright info along with server info
	winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.');
	winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
	winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
	winston.info('');


	if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
		// Load server-side configs
		nconf.file({
			file: __dirname + '/config.json'
		});
		meta = require('./src/meta.js');

		nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/');
		nconf.set('upload_url', nconf.get('url') + 'uploads/');

		winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using Redis store at ' + nconf.get('redis:host') + ':' + nconf.get('redis:port') + '.');
		winston.info('NodeBB instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address')));

		if (process.env.NODE_ENV === 'development') {
			winston.info('Base Configuration OK.');
		}

		meta.configs.init(function () {
			// Initial setup for Redis & Reds
			var reds = require('reds'),
				RDB = require('./src/redis.js');

			reds.createClient = function () {
				return reds.client || (reds.client = RDB);
			};

			var templates = require('./public/src/templates.js'),
				translator = require('./public/src/translator.js'),
				webserver = require('./src/webserver.js'),
				SocketIO =  require('socket.io').listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket']}),
				websockets = require('./src/websockets.js'),
				posts = require('./src/posts.js'),
				plugins = require('./src/plugins'), // Don't remove this - plugins initializes itself
				Notifications = require('./src/notifications'),
				Upgrade = require('./src/upgrade');

			Upgrade.check(function(schema_ok) {
				if (schema_ok || nconf.get('check-schema') === false) {
					websockets.init(SocketIO);

					global.templates = {};
					global.translator = translator;

					translator.loadServer();

					var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;

					// todo: replace below with read directory code, derp.
					templates.init([
						'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index',
						'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext',
						'emails/header', 'emails/footer',

						'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic'
					], customTemplates);


					templates.ready(webserver.init);

					Notifications.init();
				} else {
					winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
					winston.warn('    node app --upgrade');
					winston.warn('To ignore this error (not recommended):');
					winston.warn('    node app --no-check-schema')
					process.exit();
				}
			});
		});
	} else if (nconf.get('setup') || !fs.existsSync(__dirname + '/config.json')) {
		// New install, ask setup questions
		if (nconf.get('setup')) {
			winston.info('NodeBB Setup Triggered via Command Line');
		} else {
			winston.warn('Configuration not found, starting NodeBB setup');
		}

		nconf.file({
			file: __dirname + '/config.json'
		});

		var install = require('./src/install');

		winston.info('Welcome to NodeBB!');
		winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');
		winston.info('Press enter to accept the default setting (shown in brackets).');

		install.setup(function (err) {
			if (err) {
				winston.error('There was a problem completing NodeBB setup: ', err.message);
			} else {
				winston.info('NodeBB Setup Completed. Run \'node app\' to manually start your NodeBB server.');
			}

			process.exit();
		});

	} else if (nconf.get('upgrade')) {
		nconf.file({
			file: __dirname + '/config.json'
		});
		meta = require('./src/meta.js');

		meta.configs.init(function () {
			require('./src/upgrade').upgrade();
		});
	} else/* if (nconf.get('help') */{
		winston.info('Usage: node app [options] [arguments]');
		winston.info('       [NODE_ENV=development | NODE_ENV=production] node app [--start] [arguments]');
		winston.info('');
		winston.info('Options:');
		winston.info('  --help              displays this usage information');
		winston.info('  --setup             configure your environment and setup NodeBB');
		winston.info('  --upgrade           upgrade NodeBB, first read: github.com/designcreateplay/NodeBB/wiki/Upgrading-NodeBB');
		winston.info('  --start             manually start NodeBB (default when no options are given)');
	};
}());
Example #21
0
winston.beforeConfig = function () {
    winston.remove(winston.transports.Console);
    winston.add(winston.transports.Console, {level: 'info', colorize: true, timestamp: true});
};
Example #22
0
function initializeLogger() {
	logModule.add(logModule.transports.File, { filename: 'samelogger.log' });
	logModule.remove(logModule.transports.Console);
	logModule.level = 'info';
	logger = logModule;
};
Example #23
0
File: api.js Project: abner/testem
Api.prototype.configureLogging = function(){
    log.remove(log.transports.Console)
    if (this.config.get('debug')){
        log.add(log.transports.File, {filename: 'testem.log'})
    }
}
Example #24
0
     * @typedef {object} Frontend.State.Log
     * @property {string} level - The level of the log message.
     * @property {string} message - The message of the log entry.
     * @property {object} meta - Meta Information
     * @property {number} time - Time when the message was recorded.
     */
    state.logs.push({
        "level": level,
        "message": msg,
        "meta": meta,
        "time": (new Date()).toString()
    })
    callback(null, true);
};

logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {
  prettyPrint: true,
  colorize: true,
  silent: false,
  timestamp: true
});

logger.add(StoreLogger);


//Files to load
var files = [
    //init run
    "init/00_legal",
    "init/01_env",
Example #25
0
exports.init = function (_logLevel, filename) {
  logLevel = _logLevel || 3;

  winston.add(winston.transports.File, {filename: filename});
  winston.remove(winston.transports.Console);
};
Example #26
0
var max = 10
var blog = bunyan.createLogger({
  name: 'myapp',
  streams: [{
    level: 'trace',
    stream: dest
  }]
})

require('bole').output({
  level: 'info',
  stream: dest
})

winston.add(winston.transports.File, { filename: '/dev/null' })
winston.remove(winston.transports.Console)

var run = bench([
  function benchBunyan (cb) {
    for (var i = 0; i < max; i++) {
      blog.info('hello world')
    }
    setImmediate(cb)
  },
  function benchWinston (cb) {
    for (var i = 0; i < max; i++) {
      winston.info('hello world')
    }
    setImmediate(cb)
  },
  function benchBole (cb) {
Example #27
0
 static deactivateFileLogging() {
   winston.remove(winston.transports.File);
 }