Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't log requests when socket.io enabled

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.

like image 569
George Armhold Avatar asked Dec 07 '25 03:12

George Armhold


1 Answers

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
like image 191
Andrew Lavers Avatar answered Dec 08 '25 18:12

Andrew Lavers