From 4cdf41a899be8e7496c73a00b78d73ff361002b3 Mon Sep 17 00:00:00 2001 From: alexandrubratu8x8 <77101287+alexandrubratu8x8@users.noreply.github.com> Date: Tue, 29 Nov 2022 11:03:38 +0200 Subject: [PATCH] increase logging (#7) --- .gitignore | 3 ++- package.json | 1 + src/index.ts | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 0223926..e237973 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store dist -node_modules \ No newline at end of file +node_modules +deploy.sh \ No newline at end of file diff --git a/package.json b/package.json index 0022fd5..1a02523 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "lint": "eslint .", "lint-fix": "eslint . --fix", "start": "tsc && node dist/index.js", + "start:local": "tsc && DEBUG='engine,app,socket.io:client,server' node dist/index.js", "start:dev": "cross-env NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts" }, "devDependencies": { diff --git a/src/index.ts b/src/index.ts index d02b0aa..42cf894 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,10 +47,10 @@ prometheus.metrics(io, { }); io.on('connection', socket => { - ioDebug('connection established!'); + serverDebug(`connection established! ${socket.conn.request.url}`); io.to(`${socket.id}`).emit('init-room'); socket.on('join-room', roomID => { - socketDebug(`${socket.id} has joined ${roomID}`); + serverDebug(`${socket.id} has joined ${roomID} for url ${socket.conn.request.url}`); socket.join(roomID); if (io.sockets.adapter.rooms[roomID].length <= 1) { io.to(`${socket.id}`).emit('first-in-room'); @@ -66,7 +66,7 @@ io.on('connection', socket => { socket.on( 'server-broadcast', (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => { - socketDebug(`${socket.id} sends update to ${roomID}`); + serverDebug(`${socket.id} sends update to ${roomID}`); socket.broadcast.to(roomID).emit('client-broadcast', encryptedData, iv); } ); @@ -74,7 +74,7 @@ io.on('connection', socket => { socket.on( 'server-volatile-broadcast', (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => { - socketDebug(`${socket.id} sends volatile update to ${roomID}`); + serverDebug(`${socket.id} sends volatile update to ${roomID}`); socket.volatile.broadcast .to(roomID) .emit('client-broadcast', encryptedData, iv);