socketio / socketio/socket.io

Ability to change logging function

Open
#4,482 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

Is your feature request related to a problem? Please describe.
Our app uses winston to send logs to different targets, e.g. log files. However, the Logs of socket.io are sent directly to the console via debug, and therefore missing from our log files.

Describe the solution you'd like
I'd like to be able to somewhere specify a function that should be called when a log is emitted, overriding the internal "console.log" call with my own logger.

Describe alternatives you've considered
While it seems that debug can specify a global logger override (e.g. import { debug } from "debug"; debug.log = (...args: any[]) => { console.log("x", args); };), it appears that only applies to the current package. For example:

  • If I set it in my main app, all output from debug from my main app gets routed through the function above, while all socket.io logs are still using just console.log.
  • If I add debug_1.log = (...args) => { console.log("message from engine.io", args); }; by hand in node_modules/engine.io/build/server.js after const debug_1 = require("debug");, all calls from engine.io use that log function, but socket.io:client messages are still using console.log.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the debug usage described in engine.io/build/server.js and compare it with the socket.io:client logging path. Define where a logger callback can be configured across these packages, then verify that engine.io and socket.io:client messages reach it instead of direct console output.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.