dl
Version:
DreamLab Libs
41 lines (27 loc) • 899 B
JavaScript
var events = require('events');
var EventEmitter = events.EventEmitter;
var AbstractReporter = function () {
EventEmitter.call(this);
this._config = {};
this._stats = {};
};
AbstractReporter.prototype = Object.create(EventEmitter.prototype);
AbstractReporter.prototype.setConfig = function (config) {
this._config = config;
return this;
};
AbstractReporter.prototype.gauge = function () {};
AbstractReporter.prototype.counter = function () {};
AbstractReporter.prototype._reportStats = function (metric, value) {
value = (value === undefined) ? 1 : value;
this._stats[metric] = (this._stats[metric] + value) || value;
return this;
};
AbstractReporter.prototype.getStats = function () {
return this._stats;
};
AbstractReporter.prototype.flushStats = function () {
this._stats = {};
return this;
};
exports.AbstractReporter = AbstractReporter;