Skip to content

Commit

Permalink
Merge pull request statsd#296 from etsy/pet_syntaxchecker
Browse files Browse the repository at this point in the history
add jshint comment and do a little cleanup
  • Loading branch information
draco2003 committed May 15, 2013
2 parents 7278d8b + 0e19c41 commit eb8d81d
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 20 deletions.
6 changes: 4 additions & 2 deletions backends/console.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true, laxcomma:true */

var util = require('util');

function ConsoleBackend(startupTime, config, emitter){
Expand All @@ -9,7 +11,7 @@ function ConsoleBackend(startupTime, config, emitter){
// attach
emitter.on('flush', function(timestamp, metrics) { self.flush(timestamp, metrics); });
emitter.on('status', function(callback) { self.status(callback); });
};
}

ConsoleBackend.prototype.flush = function(timestamp, metrics) {
console.log('Flushing stats at', new Date(timestamp * 1000).toString());
Expand All @@ -22,7 +24,7 @@ ConsoleBackend.prototype.flush = function(timestamp, metrics) {
counter_rates: metrics.counter_rates,
sets: function (vals) {
var ret = {};
for (val in vals) {
for (var val in vals) {
ret[val] = vals[val].values();
}
return ret;
Expand Down
2 changes: 2 additions & 0 deletions backends/graphite.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true, laxcomma:true */

/*
* Flush stats to graphite (http://graphite.wikidot.com/).
*
Expand Down
12 changes: 8 additions & 4 deletions backends/repeater.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
var util = require('util'),
dgram = require('dgram'),
logger = require('../lib/logger');
/*jshint node:true, laxcomma:true */

var util = require('util')
, dgram = require('dgram')
, logger = require('../lib/logger');

var l;
var debug;

function RepeaterBackend(startupTime, config, emitter){
var self = this;
this.config = config.repeater || [];
Expand All @@ -17,7 +21,7 @@ function RepeaterBackend(startupTime, config, emitter){
});
// attach
emitter.on('packet', function(packet, rinfo) { self.process(packet, rinfo); });
};
}

RepeaterBackend.prototype.process = function(packet, rinfo) {
var self = this;
Expand Down
4 changes: 3 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*jshint node:true, laxcomma:true */

var fs = require('fs')
, util = require('util')
, util = require('util');

var Configurator = function (file) {

Expand Down
16 changes: 9 additions & 7 deletions lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*jshint node:true, laxcomma:true */

var Logger = function (config) {
this.config = config;
this.backend = this.config.backend || 'stdout'
this.level = this.config.level || "LOG_INFO"
this.backend = this.config.backend || 'stdout';
this.level = this.config.level || "LOG_INFO";
if (this.backend == 'stdout') {
this.util = require('util');
} else {
if (this.backend == 'syslog') {
this.util = require('node-syslog');
this.util.init(config.application || 'statsd', this.util.LOG_PID | this.util.LOG_ODELAY, this.util.LOG_LOCAL0);
} else {
throw "Logger: Should be 'stdout' or 'syslog'."
throw "Logger: Should be 'stdout' or 'syslog'.";
}
}
}
};

Logger.prototype = {
log: function (msg, type) {
Expand All @@ -23,7 +25,7 @@ Logger.prototype = {
this.util.log(type + ": " + msg);
} else {
if (!type) {
type = this.level
type = this.level;
if (!this.util[type]) {
throw "Undefined log level: " + type;
}
Expand All @@ -33,6 +35,6 @@ Logger.prototype = {
this.util.log(this.util[type], msg);
}
}
}
};

exports.Logger = Logger
exports.Logger = Logger;
1 change: 1 addition & 0 deletions lib/mgmt_console.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true, laxcomma:true */

/**
* delete_stats - delete all matching statistics
Expand Down
6 changes: 4 additions & 2 deletions lib/process_metrics.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true, laxcomma:true */

var process_metrics = function (metrics, flushInterval, ts, flushCallback) {
var starttime = Date.now();
var key;
Expand Down Expand Up @@ -122,6 +124,6 @@ var process_metrics = function (metrics, flushInterval, ts, flushCallback) {
metrics.statsd_metrics = statsd_metrics;

flushCallback(metrics);
}
};

exports.process_metrics = process_metrics
exports.process_metrics = process_metrics;
8 changes: 5 additions & 3 deletions lib/set.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*jshint node:true, laxcomma:true */

var Set = function() {
this.store = {};
}
};

Set.prototype = {
has: function(value) {
Expand All @@ -20,11 +22,11 @@ Set.prototype = {
},
values: function() {
var values = [];
for (value in this.store) {
for (var value in this.store) {
values.push(value);
}
return values;
}
}
};

exports.Set = Set;
4 changes: 3 additions & 1 deletion stats.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jshint node:true, laxcomma:true */

var dgram = require('dgram')
, util = require('util')
, net = require('net')
Expand All @@ -7,7 +9,7 @@ var dgram = require('dgram')
, logger = require('./lib/logger')
, set = require('./lib/set')
, pm = require('./lib/process_metrics')
, mgmt = require('./lib/mgmt_console')
, mgmt = require('./lib/mgmt_console');


// initialize data structures with defaults for statsd stats
Expand Down

0 comments on commit eb8d81d

Please sign in to comment.