I'm trying to debug a socket.io problem. In order to figure out what's happening, I'd like to log all requests, so I have installed morgan.
var express = require('express');
var app = express();
app.use(require('morgan')('dev'));
var path = require('path');
var http = require('http').Server(app);
var io = require('socket.io')(http); // this line prevents morgan from logging
Logging works fine until I require socket.io- that last line there apparently prevents morgan from seeing all the requests.
Why is socket.io preventing the rest of the stack from seeing requests?
Edit:
Something of an explanation here: apparently socket.io is too verbose, and debugging is turned off by default. If I run with DEBUG=* set in my environment, I get lots more information.
This does seem rather unfriendly to the rest of the stack though.
Yes DEBUG=* can be way too verbose but the debug module also lets you specify comma separated list of wildcardable patterns. Some examples:
DEBUG=socket.io*
DEBUG=socket.io*,engine:*
DEBUG=socket.io:socket,engine:socket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With