Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #563 from 3rd-Eden/logger

Logger
  • Loading branch information...
commit 175fe8573b00463d824646a8cbda8066ab1eb80b 2 parents 0224e4a + 0b7ed64
@rauchg rauchg authored
View
3  lib/logger.js
@@ -60,6 +60,7 @@ var Logger = module.exports = function (opts) {
opts = opts || {}
this.colors = false !== opts.colors;
this.level = 3;
+ this.enabled = true;
};
/**
@@ -71,7 +72,7 @@ var Logger = module.exports = function (opts) {
Logger.prototype.log = function (type) {
var index = levels.indexOf(type);
- if (index > this.level)
+ if (index > this.level || !this.enabled)
return this;
console.log.apply(
View
6 lib/manager.js
@@ -69,6 +69,7 @@ function Manager (server, options) {
, authorization: false
, blacklist: ['disconnect']
, 'log level': 3
+ , 'log colors': true
, 'close timeout': 25
, 'heartbeat timeout': 15
, 'heartbeat interval': 20
@@ -148,10 +149,11 @@ Manager.prototype.__defineGetter__('store', function () {
*/
Manager.prototype.__defineGetter__('log', function () {
- if (this.disabled('log')) return;
-
var logger = this.get('logger');
+
logger.level = this.get('log level') || -1;
+ logger.colors = this.get('log colors');
+ logger.enabled = this.enabled('log');
return logger;
});
View
43 test/manager.test.js
@@ -517,5 +517,48 @@ module.exports = {
io.get('custom').should.equal('opt');
io.server.close();
done();
+ },
+
+ 'test disabling the log': function (done) {
+ var port = ++ports
+ , io = sio.listen(port, { log: false })
+ , _console = console.log
+ , calls = 0;
+
+ // the logger uses console.log to output data, override it to see if get's
+ // used
+ console.log = function () { ++calls };
+
+ io.log.debug('test');
+ io.log.log('testing');
+
+ console.log = _console;
+ calls.should.equal(0);
+
+ io.server.close();
+ done();
+ },
+
+ 'test disabling logging with colors': function (done) {
+ var port = ++ports
+ , io = sio.listen(port, { 'log colors': false })
+ , _console = console.log
+ , calls = 0;
+
+ // the logger uses console.log to output data, override it to see if get's
+ // used
+ console.log = function (data) {
+ ++calls;
+ data.indexOf('\033').should.equal(-1);
+ };
+
+ io.log.debug('test');
+ io.log.log('testing');
+
+ console.log = _console;
+ calls.should.equal(2);
+
+ io.server.close();
+ done();
}
};
View
24 test/static.test.js
@@ -519,5 +519,27 @@ module.exports = {
io.server.close();
done();
});
- }
+ },
+
+ 'test that etags are ignored for versioned requests': function (done) {
+ var port = ++ports
+ , io = sio.listen(port)
+ , cl = client(port);
+
+ io.enable('browser client etag');
+
+ cl.get('/socket.io/socket.io.v0.8.9.js', function (res, data) {
+ should.strictEqual(res.headers.etag, undefined);
+ res.headers['content-type'].should.eql('application/javascript');
+ res.headers['content-length'].should.match(/([0-9]+)/);
+ res.headers['cache-control']
+ .indexOf(io.get('browser client expires')).should.be.above(-1);
+
+ data.should.match(/XMLHttpRequest/);
+
+ cl.end();
+ io.server.close();
+ done();
+ });
+ },
};
Please sign in to comment.
Something went wrong with that request. Please try again.