Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = () => {
const logDir = '../logs';
// Create log directory if it does not exist
if (!fs.existsSync(logDir)) fs.mkdirSync(logDir);
// Log to console
logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {
colorize: true,
level: 'debug',
timestamp: moment().utc().format(),
});
// Log to file
logger.add(logger.transports.File, {
filename: `${logDir}/-results.log`,
json: false,
level: 'info',
prepend: true,
timestamp: moment().utc().format(),
});
// Log to Loggly
logger.add(logger.transports.Loggly, {
// Require modules
var request = require('request').debug = true;
var winston = require('winston');
// Prepare log file
winston.add(winston.transports.File, { filename: 'logs/initialization_responses.log' });
// Set the headers
var http_headers = {
'User-Agent': 'Super Agent/0.0.1',
'Content-Type': 'application/vnd.cip4-jmf+xml'
}
// Var
var idp_endpoint = 'http://192.168.1.40:8080/prodflow/jmf/HP-Indigo-BUDPB';
var jmf_subscription_server = 'http://192.168.1.70:9090';
var jmf_payload = '';
// Configure the request
var options = {
url: idp_endpoint,
const winstonOptions = {
colorize: true,
timestamp: true,
handleExceptions: true,
prettyPrint: true,
};
if (process.env.LOG_LEVEL) {
winstonOptions.level = process.env.LOG_LEVEL;
} else if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
winstonOptions.level = 'debug';
} else {
winstonOptions.level = 'info';
}
winston.add(winston.transports.Console, winstonOptions);
const app = express();
if (settings.server.useCors) {
app.use(cors());
}
// Initialisations
require('./init')(nconf).then(() => {
appRoutes(app);
const server = app.listen(process.env.PORT || settings.server.runPort, () => {
winston.info('Server listening', {
host: server.address().address,
port: server.address().port,
});
});
main: "relay.js",
name: "relay",
pidfile: "relay.pid"
});
var options = {
hostname: "forever.fm",
path: "/all.mp3",
headers: {"Connection": "keep-alive"}
};
var port = 8192;
var listeners = [];
var timeout = 1000; // ms
winston.level = 'log';
winston.add(winston.transports.File, { filename: 'relay.log', handleExceptions: true });
var check = function(callback) {
winston.info("Attempting to connect to generator...");
check_opts = {'method': 'HEAD'};
for (var a in options) check_opts[a] = options[a];
req = http.request(check_opts, function (res) {
if ( res.statusCode != 200 ) {
winston.error("OH NOES: Got a " + res.statusCode);
} else {
winston.info("Got 200 back from generator!")
if (typeof callback != "undefined") callback();
}
})
req.end();
}
this.update = (config) => {
if (!config) {
return winston.warn('No slack config received');
}
// update variables
winston.info('configuring slack logger...');
const {slackWebHook, slackErrorChannel, slackInfoChannel} = config;
this.slackWebHook = slackWebHook;
this.slackErrorChannel = slackErrorChannel;
this.slackInfoChannel = slackInfoChannel;
// update slack webhook settings
if (this.slackWebHook) {
// add a transport for errors to slack
if (this.slackErrorChannel) {
winston.add(winstonSlackWebHook, {
name : 'slack-errors-transport',
level : 'warn',
webhookUrl: this.slackWebHook,
channel : this.slackErrorChannel,
username : 'spee.ch',
iconEmoji : ':face_with_head_bandage:',
});
};
if (this.slackInfoChannel) {
winston.add(winstonSlackWebHook, {
name : 'slack-info-transport',
level : 'info',
webhookUrl: this.slackWebHook,
channel : this.slackInfoChannel,
username : 'spee.ch',
iconEmoji : ':nerd_face:',
var config = require('./config')();
if (config.bugtracking) {
require('./bugsense').init('credentials-helper');
}
var winston = require('winston');
var path = require('path');
if (config.logDirectory)
winston.add(winston.transports.File, { filename: path.join(config.logDirectory, 'credentials-helper.log'), maxsize: 100*1024, maxFiles: 2 });
winston.remove(winston.transports.Console);
winston.info('Credentials helper invoked');
var superagent = require('superagent');
if (process.argv[3] == 'get') {
winston.info('Getting credentials');
superagent.agent().get('http://localhost:' + config.port + '/api/credentials?socketId=' + process.argv[2]).end(function(err, res) {
if (err || !res.ok) {
winston.error('Error getting credentials', err);
throw err;
}
winston.info('Got credentials');
console.log('username=' + res.body.username);
console.log('password=' + res.body.password);
});
password = m.settings[2],
storeDetails = m.settings[3],
followRedirects = m.settings[4],
proxy = m.settings[5],
sanitise = m.settings[6],
url = m.settings[7],
type = m.settings[8],
container = m.settings[9],
evt = m.settings[10],
xPath = m.settings[11],
config = m.settings[12],
client = redis.createClient(config.redis.port, config.redis.hostname);
winston.cli();
winston.remove(winston.transports.Console);
winston.add(
winston.transports.Console,
{
level: config.logging.level,
silent: config.logging.silent,
colorize: true,
timestamp: true
}
);
var crawler = new Crawler(config, spawn, test, client, winston, fs, optimist, utils);
crawler.init();
crawler.timeStart = timeStart;
crawler.username = username;
crawler.password = password;
crawler.storeDetails = storeDetails;
crawler.followRedirects = followRedirects;
exports.run = function(config_filepath, opts) {
opts = _.extend({logfile: false, osx: false}, opts);
if (opts.logfile) {
logger.add(logger.transports.File, {filename: opts.logfile});
}
if (opts.osx) {
var NotificationCenterTransport = require('winston-notification-center');
logger.add(NotificationCenterTransport, {title: 'File system watcher'});
}
var file_watchers = [];
var restart = function() {
logger.debug('Stopping %d FileWatchers', file_watchers.length);
_.invoke(file_watchers, 'stop');
file_watchers.length = 0;
config.read(config_filepath, function(err, new_file_watchers) {
if (err) {
logger.error('Error reading config: %s', err);
process.exit(1);
}
Array.prototype.push.apply(file_watchers, new_file_watchers);
logger.debug('Starting %d FileWatchers', file_watchers.length);
module.exports = function () {
winston.handleExceptions(
new winston.transports.Console({ colorize: true, prettyPrint: true }),
new winston.transports.File({ filename: 'uncaughtExceptions.log' })
);
process.on('unhandledRejection', (ex) => {
throw ex;
});
winston.add(winston.transports.File, { filename: 'logfile.log' });
}
exports.setup = function (options, config) {
removeTransports([winston.transports.Console, StealTransport]);
winston.add(StealTransport, {
level: options.verbose ? 'debug' : 'info',
colorize: true,
silent: options.quiet && !options.verbose
});
if(options.quiet && config) {
config.logLevel = 3;
} else if(options.verbose && config) {
config.logLevel = 0;
}
};