How to do log to file?

Due to lack of built-in support for logging to file, do you have any advice? Wrap the console.log? Grab the stdout/stderr just like what pm2 does?

No idea, honestly. However AFAIK systemd and modern deployment systems (i.e. based on Docker) already use stdout/stderr as log destination and provide tools to redirect them to files when appropriate. Wrapping console.log/warn/error may also work but I’ve never done that.

Anyway, there are tons of Node libraries (such as Express) that also use the debug library for logging.

Express benefits widely from middlewares:

const app = express()
const loggingMiddleware = require('my-logging-middleware')
app.use(loggingMiddleware)

For mediasoup you may simply call a middleware function in the logger.

Not sure what exactly you mean. Perhaps implement/allow “middlewares in mediasoup for custom logging”?

Yes, as Design Goals say, being minimalist but providing ways for integration.

It would be a nice to have feature. However we already spend LOT of time in improving mediasoup and making it free for anyone to use. For certain features we do not need we would require then to be funded by users.

Perhaps I can work on it if is desired.

Sure. Just take into account that there is a Logger.js class with 3 separate debug instances so that class should be the one that, instead of those debug instances, use another stuff for logging.

Okay, I’ll try to prepare a proposal first.

BTW setting the logLevel to none I’m still getting logs in the console:

mediasoup.createWorker({
  logLevel: 'none',
  ...
});
spawning worker process: ../mediasoup-worker --logLevel=none

What’s wrong?

Nothing is wrong. logLevel just affects log created by the worker process and not by the JavaScript.