Moved the curl formatting into the log and changed the arguments for the log event listeneres to

receive both the "message" and the "curlCommand".

Added a "tracer" logger which allows you to create log files that a executable scripts. Those scripts
will write all of the log messages as script comments, and not comment out the curlCommands, so that they
can trace their application and use the generated script to recreate the issue.

Most changes are simply cased by adding the "unused" rule to jshint.
This commit is contained in:
Spencer Alger
2013-11-15 19:10:45 -07:00
parent 20804bb5ab
commit 5bb70fbe58
32 changed files with 185 additions and 229 deletions

View File

@ -23,7 +23,7 @@ module.exports = function (path) {
function rmDirRecursive(path) {
fs.readdirSync(path).forEach(function (file, index) {
fs.readdirSync(path).forEach(function (file) {
var curPath = path + '/' + file;
if (fs.statSync(curPath).isDirectory()) { // recurse
rmDirRecursive(curPath);

View File

@ -64,7 +64,7 @@ function transformFile(entry) {
}
var urls = _.difference(def.url.paths, aliases[name]);
urls = _.map(urls, function (url, i) {
urls = _.map(urls, function (url) {
var optionalVars = {};
var requiredVars = {};
var param;

View File

@ -1,21 +1,14 @@
var _ = require('../../../src/lib/utils');
var asset = require('assert');
var path = require('path');
var fs = require('fs');
var mkdirp = require('mkdirp');
var templates = require('./templates');
var clean = require('../../clean');
var restSpecUpdated = require('../../rest_spec_updated');
var urlParamRE = /\{(\w+)\}/g;
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
var docOutputPath = _.joinPath(__dirname, '../../../docs/api.md');
var lastFetchTmp = path.join(__dirname, './last_fetch.tmp');
function download() {
require('./actions').on('ready', function (actions) {
var defs = [];
var namespaces = _.filter(_.map(actions, function (action) {
if (~action.location.indexOf('.')) {
var path = action.location.split('.').slice(0, -1);

View File

@ -1,8 +1,6 @@
/* jshint maxlen: false */
var ca = require('./client_action');
var errors = require('./errors');
var api = module.exports = {};
api._namespaces = <%= stringify(namespaces) %>;<%

View File

@ -4,48 +4,6 @@ var fs = require('fs');
var path = require('path');
/**
* Simple manager to take care of indentation
* @param {number} i - Width of the indentation
* @return {function} - Call this to add a new line to the output
*/
function lines(i) {
function l(line) {
if (line === '') {
// no indent on empty lines
l.lines.push('');
} else if (line === void 0) {
l.lines.push(_.repeat(' ', l.indent) + line);
}
return l;
}
l.lines = [];
l.indent = i || 0;
l.split = function (toSplit) {
_.each(toSplit.split(/\r?\n/), l);
return l;
};
l.in = function (line) {
l.indent += 2;
return l(line);
};
l.out = function (line) {
l.indent -= 2;
return l(line);
};
l.toString = function () {
return l.lines.join('\n');
};
return l;
}
/**
* we want strings in code to use single-quotes, so this will JSON encode vars, but then
* modify them to follow our code standards.

View File

@ -45,7 +45,6 @@ if (argv.host) {
}
var client = new es.Client(clientConfig);
var log = client.config.log;
console.log('Generating', count, 'events across ±', days, 'days');

View File

@ -1,10 +1,9 @@
var _ = require('../../../../src/lib/utils'),
WeightedList = require('./weighted_list'),
RandomList = require('./random_list'),
IpGenerator = require('./ip_generator'),
Stochator = require('./stochator'),
moment = require('moment'),
dayMs = 86400000;
var _ = require('../../../../src/lib/utils');
var WeightedList = require('./weighted_list');
var RandomList = require('./random_list');
var IpGenerator = require('./ip_generator');
var Stochator = require('./stochator');
var dayMs = 86400000;
exports.make = function (startingMoment, endingMoment) {

View File

@ -4,8 +4,6 @@
module.exports = RandomList;
var _ = require('../../../../src/lib/utils');
function RandomList(list) {
this.get = function () {
return list[Math.round(Math.random() * list.length)];

View File

@ -7,7 +7,6 @@ var path = require('path');
var jsYaml = require('js-yaml');
var spec = require('../../get_spec');
var clean = require('../../clean');
var _ = require('../../../src/lib/utils');
var restSpecUpdated = require('../../rest_spec_updated');
var testFile = path.resolve(__dirname, '../../../test/integration/yaml_suite/yaml_tests.json');

View File

@ -1,5 +1,4 @@
var http = require('http'),
async = require('async');
var http = require('http');
var server = http.createServer(function (req, resp) {
var closed, count = 0;

View File

@ -1,46 +1,70 @@
var es = require('../src/elasticsearch');
var async = require('async');
var argv = require('optimist').default({
indx: 'test-docs',
type: 'test-doc',
warm: 10000,
docs: 100000,
sync: false,
sock: 100
})
.boolean('sync')
.argv;
function getMs() {
var hr = process.hrtime();
return (hr[0] * 1e9 + hr[1]) / 1e6;
function hrtime(start) {
var hr = start ? process.hrtime(start) : process.hrtime();
return start ? Math.round(((hr[0] * 1e9 + hr[1]) / 1e6) * 100) / 100 : hr;
}
var client = new es.Client({
hosts: 'localhost:9200',
log: null,
maxSockets: 100
maxSockets: argv.sock
});
async.series([
function (done) {
console.log('clearing existing "test-docs" indices');
console.log('removing existing "%s" index', argv.indx);
client.indices.delete({
index: 'test-docs',
index: argv.indx,
ignore: 404
}, done);
},
function (done) {
console.log('waiting for cluster');
client.cluster.health({
wait_for_status: 'yellow'
console.log('creating new "%s" index', argv.indx);
client.indices.create({
index: argv.indx,
body: {}
}, done);
},
function (done) {
var times = 1e4;
console.log('creating %d docs', times);
var start = getMs();
async.times(times, function (i, done) {
console.log('warnming up index with %d docs', argv.warm);
async.times(argv.warm, function (i, done) {
client.index({
index: 'test-docs',
type: 'test-doc',
index: argv.indx,
type: argv.type,
body: {}
}, done);
}, done);
},
function (done) {
console.log('waiting for cluster to go yellow');
client.cluster.health({
waitForStatus: 'yellow'
}, done);
},
function (done) {
console.log('creating %d docs ' + (async.sync ? 'in series' : argv.sock + ' requests at a time'), argv.docs);
var start = hrtime();
async[argv.sync ? 'timesSeries' : 'times'](argv.docs, function (i, done) {
client.index({
index: argv.indx,
type: argv.type,
body: {}
}, done);
}, function (err) {
console.log('complete in', Math.round((getMs() - start) * 100) / 100, 'ms');
if (err) {
client.config.log.error(err);
}
console.log('complete in', hrtime(start), 'ms');
done(err);
});
}
], function (err) {