Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const http = require('http')
const fs = require('fs')
const path = require('path')
var os = require('os')
const machineName = os.hostname()
const processId = process.pid
const azure = require('azure-storage')
const storageService = azure.createTableService()
const storageTargetName = 'completechecks'
const entityGenerator = azure.TableUtilities.entityGenerator
const uuid = require('uuidv4')
const debug = process.env.NODE_ENV !== 'production'
let logger
if (process.env.LOGZ_KEY) {
logger = require('logzio-nodejs').createLogger({
token: process.env.LOGZ_KEY,
host: 'listener.logz.io',
type: 'wac-spike-mtc'
})
}
const log = (data) => {
if (logger) {
logger.log(data)
}
}
// grab disk data...
let buildId
try {
buildId = fs.readFileSync(path.join(__dirname, 'build.txt'))
var RotatingFileStream = require('../index');
var bunyan = require('bunyan');
var uuid = require('uuid');
var mkdirp = require('mkdirp');
var EventEmitter = require('events').EventEmitter;
var logzionodejs = require('logzio-nodejs');
var fs = require('fs');
var async = require('async');
var path = require('path');
var apikey = process.argv[2];
var logzio;
if (apikey && apikey !== 'local') {
logzio = logzionodejs.createLogger({
token: apikey,
type: 'rfs ' + process.version
});
} else {
logzio = {log: function() {}};
}
var _ = require('lodash');
var Combinatorics = require('js-combinatorics');
var combinations = {
level: ['debug', 'info', 'warn', 'error', 'fatal'],
period: ['1m', '1h', '1d', '1m', ''],
threshold: [0, 1, 10240, '100k', '1m', '1g'],
totalFiles: [0, 1, 2, 5, 10, 20],
totalSize: [0, '100k', '1m', '10m', '100m', '1g'],
module.exports = function processEventHubMessages(context, eventHubMessages, { enableMetric = false }) {
const { host, token } = enableMetric ? parserOptions.metrics : parserOptions.logs;
context.log(`Starting Logz.io Azure function with enableMetrics: ${enableMetric}`);
context.log(JSON.stringify(eventHubMessages));
const callBackFunction = getCallBackFunction(context);
const logzioShipper = logger.createLogger({
token,
host,
type: 'eventHub',
protocol: 'https',
internalLogger: context,
compress: true,
debug: true,
callback: callBackFunction,
});
const dataParser = new DataParser({
internalLogger: context,
enableMetric,
});
const parseMessagesArray = dataParser.parseEventHubLogMessagesToArray(eventHubMessages);
const logger = process.env.LOGZIO_TOKEN
? require('logzio-nodejs').createLogger({
token: process.env.LOGZIO_TOKEN,
host: 'listener.logz.io'
})
: console
module.exports = (action, req) => {
logger.log({
message: req.params.url,
action,
webp: req.params.webp,
ip: req.ip,
origin_type: req.params.originType,
origin_size: req.params.originSize,
...req.log
})
}
prettyStdOut.pipe(process.stdout);
const bunyanLogger = bunyan.createLogger({
name: env,
streams: [
{
level: 'debug',
type: 'raw',
stream: prettyStdOut,
},
],
});
let logzIoLogger;
if (process.env.logzIoAccessToken) {
logzIoLogger = logzIo.createLogger({
token: process.env.logzIoAccessToken,
type: 'api',
});
}
let logdnaLogger;
if (process.env.logdnaApiKey) {
logdnaLogger = logdna.createLogger(process.env.logdnaApiKey, {
env,
hostname: os.hostname(),
ip: ip.address(),
});
}
function setLevel(level) {
switch (level) {
module.exports = function processEventHubMessages(context, eventHubMessages, {
enableMetric = false,
}) {
const {
host,
token,
} = enableMetric ? getParserOptions().metrics : getParserOptions().logs;
context.log(`Starting Logz.io Azure function with enableMetrics: ${enableMetric}`);
context.log(JSON.stringify(eventHubMessages));
const callBackFunction = getCallBackFunction(context);
const logzioShipper = logger.createLogger({
token,
host,
type: 'eventHub',
protocol: 'https',
internalLogger: context,
compress: true,
debug: true,
callback: callBackFunction,
});
const dataParser = new DataParser({
internalLogger: context,
enableMetric,
});
const parseMessagesArray = dataParser.parseEventHubLogMessagesToArray(eventHubMessages);