fluent-logger
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -25,9 +25,10 @@ 'use strict'; | ||
// delegate logger interfaces to default sender object | ||
var methods = ['emit', 'end', 'addListener', 'on', 'once', 'removeListener', 'removeAllListeners']; | ||
var methods = ['emit', 'end', 'addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners']; | ||
methods.forEach(function(attr, i){ | ||
module.exports[attr] = function(){ | ||
if( sender ){ | ||
sender[attr].apply(sender, Array.prototype.slice.call(arguments)); | ||
return sender[attr].apply(sender, Array.prototype.slice.call(arguments)); | ||
} | ||
return undefined; | ||
}; | ||
}); |
@@ -34,7 +34,9 @@ 'use strict'; | ||
}; | ||
['addListener', 'on', 'once', 'removeListener', 'removeAllListeners'].forEach(function(attr, i){ | ||
['addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'].forEach(function(attr, i){ | ||
appender[attr] = function(){ | ||
logSender[attr].apply(logSender, Array.prototype.slice.call(arguments)); | ||
return logSender[attr].apply(logSender, Array.prototype.slice.call(arguments)); | ||
}; | ||
}); | ||
// For Node.js v0.12 or earlier | ||
appender._eventEmitter = logSender._eventEmitter; | ||
return appender; | ||
@@ -41,0 +43,0 @@ } |
@@ -50,5 +50,5 @@ 'use strict'; | ||
['addListener', 'on', 'once', 'removeListener', 'removeAllListeners'].forEach(function(attr, i){ | ||
['addListener', 'on', 'once', 'removeListener', 'removeAllListeners', 'setMaxListeners', 'getMaxListeners'].forEach(function(attr, i){ | ||
FluentSender.prototype[attr] = function(){ | ||
this._eventEmitter[attr].apply(this._eventEmitter, Array.prototype.slice.call(arguments)); | ||
return this._eventEmitter[attr].apply(this._eventEmitter, Array.prototype.slice.call(arguments)); | ||
}; | ||
@@ -55,0 +55,0 @@ }); |
{ | ||
"name": "fluent-logger", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,2 +5,3 @@ var expect = require('chai').expect; | ||
var runServer = require('../lib/testHelper').runServer; | ||
var EventEmitter = require('events').EventEmitter; | ||
@@ -78,3 +79,17 @@ log4js.restoreConsole(); | ||
}); | ||
it('should set max listeners', function(done) { | ||
var appender = log4jsSupport.appender('debug'); | ||
if (EventEmitter.prototype.getMaxListeners) { | ||
expect(appender.getMaxListeners()).to.be.equal(10); | ||
} | ||
appender.setMaxListeners(100); | ||
if (EventEmitter.prototype.getMaxListeners) { | ||
expect(appender.getMaxListeners()).to.be.equal(100); | ||
} else { | ||
expect(appender._eventEmitter._maxListeners).to.be.equal(100); | ||
} | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,3 @@ var expect = require('chai').expect; | ||
var async = require('async'); | ||
var EventEmitter = require('events').EventEmitter; | ||
@@ -257,2 +258,16 @@ describe("FluentSender", function(){ | ||
it('should set max listeners', function(done){ | ||
var s = new sender.FluentSender('debug'); | ||
if (EventEmitter.prototype.getMaxListeners) { | ||
expect(s.getMaxListeners()).to.be.equal(10); | ||
} | ||
s.setMaxListeners(100); | ||
if (EventEmitter.prototype.getMaxListeners) { | ||
expect(s.getMaxListeners()).to.be.equal(100); | ||
} else { | ||
expect(s._eventEmitter._maxListeners).to.be.equal(100); | ||
} | ||
done(); | ||
}); | ||
// Internal behavior test. | ||
@@ -259,0 +274,0 @@ it('should not flush queue if existing connection is unavailable.', function(done){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34971
636