Custom logger support
See original GitHub issueIssue Description
Original report by @MCArth:
what might be an interesting addition to the engine would be the ability to set logging levels of colyseus (and then there be an ‘error only’ level which excludes this/seat reservation expired that could be called warnings or something) but that’s a lot of work and tbh I should just set up my own logging system haha
The disadvantage of using console.log
directly inside the Colyseus’ codebase (which we currently do) is that all internal logs are forcibly going to go to stdout, making it not possible to easily forward logs and errors to external services.
We can do exactly as the web framework fastify: use a small abstract-logging library for logs, and default it to console
to keep current functionality.
There are quite a few logging frameworks available for Node.js, such as winston
, bunyan
, pino
, etc. By using an abstract logger, end-users could provide whichever logging library they prefer:
Example providing a pino
logger:
import pino from "pino";
const transport = pino.transport({
target: 'some-transport',
options: { some: 'options for', the: 'transport' }
})
const logger = pino(transport);
const server = new Server({
// provide the custom logger.
// default: console
logger: logger,
});
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:5 (3 by maintainers)
Hi @lpsandaruwan, sounds good to me! Can we also have it optional in the
Server
constructor? Then all Colyseus configurations can be provided from a single place.This issue was closed because it has been stalled for 7 days with no activity.