Override the internal Socket.io logger
masterYou can replace the default internal logger used by go-socket.io with your own implementation by assigning a logger instance to logger.Log. This is useful for integrating Socket.io logs into your existing application logging framework (e.g., using slog).
import (
"os"
"log/slog"
"github.com/googollee/go-socket.io/logger"
)
func main() {
json_logger := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelInfo, // Set Level for each handler
})
log := slog.New(json_logger).With("server", "socket.io") // attach attribute to all log lines
logger.Log = log
}