lib/index.js
function Logger (options) {
  if (!(this instanceof Logger)) return new Logger(options);

  options = options || {};

  debug('new logger v%s', pkg.version);

  var router = Router();
  router.on(function (sock, args, cb) {
    debug('logger args.length %s', arguments.length);
    try {
      // "this" is the "socket"
      logger.stream().write(logger.format(sock, args) + "\n");
      cb();
    }
    catch (e) {
      debug('caught an error %s', e);
      console.trace(e);
      cb(e);
    }
  });

  function logger (sock, cb) {
    debug('logger sock', sock, cb.toString());
    router(sock, cb);
  }

  logger.__proto__ = Logger.prototype;

  if (options.stream) {
    logger.stream(options.stream);
  }

  if (options.format) {
    logger.format(options.format);
  }

  return logger;
}
function Logger (options) {
  if (!(this instanceof Logger)) return new Logger(options);

  options = options || {};

  debug('new logger v%s', pkg.version);

  var router = Router();
  router.on(function (sock, args, cb) {
    debug('logger args.length %s', arguments.length);
    try {
      // "this" is the "socket"
      logger.stream().write(logger.format(sock, args) + "\n");
      cb();
    }
    catch (e) {
      debug('caught an error %s', e);
      console.trace(e);
      cb(e);
    }
  });

  function logger (sock, cb) {
    debug('logger sock', sock, cb.toString());
    router(sock, cb);
  }

  logger.__proto__ = Logger.prototype;

  if (options.stream) {
    logger.stream(options.stream);
  }

  if (options.format) {
    logger.format(options.format);
  }

  return logger;
}
function Logger ( options ) { if ( ! ( this instanceof Logger ) ) return new Logger ( options ) ; options = options || { } ; debug ( 'new logger v%s' , pkg . version ) ; var router = Router ( ) ; router . on ( function ( sock , args , cb ) { debug ( 'logger args.length %s' , arguments . length ) ; try { // "this" is the "socket" logger . stream ( ) . write ( logger . format ( sock , args ) + "\n" ) ; cb ( ) ; } catch ( e ) { debug ( 'caught an error %s' , e ) ; console . trace ( e ) ; cb ( e ) ; } } ) ; function logger ( sock , cb ) { debug ( 'logger sock' , sock , cb . toString ( ) ) ; router ( sock , cb ) ; } logger . __proto__ = Logger . prototype ; if ( options . stream ) { logger . stream ( options . stream ) ; } if ( options . format ) { logger . format ( options . format ) ; } return logger ; }
A very simple middleware for socket.io that will record the events and log
them to a stream.

@return Logger
A very simple middleware for socket . io that will record the events and log them to a stream .