comment out console.log to reduce output logs
This commit is contained in:
		
							parent
							
								
									00702c4aea
								
							
						
					
					
						commit
						b37fdb40a2
					
				@ -10,10 +10,10 @@ const my = {
 | 
				
			|||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
  initSocket (webServer) {
 | 
					  initSocket (webServer) {
 | 
				
			||||||
    my.wsServer = new ws.Server({ server: webServer })
 | 
					    my.wsServer = new ws.Server({ server: webServer })
 | 
				
			||||||
    console.info({ _at: new Date().toJSON(), _from: 'Socket:initSocket', _type: 'CLOG', about: 'Base Socket Server is initialized.' }, '\n,')
 | 
					    //console.info({ _at: new Date().toJSON(), _from: 'Socket:initSocket', _type: 'CLOG', about: 'Base Socket Server is initialized.' }, '\n,')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    my.wsServer.on('connection', (socket, req) => {
 | 
					    my.wsServer.on('connection', (socket, req) => {
 | 
				
			||||||
      //console.info({_at:new Date().toJSON(), _from: 'Socket:onConnection', _type:'CLOG', about: `A socket is connecting from ${req.connection.remoteAddress}:${req.connection.remotePort}.`},'\n,')
 | 
					      //console.info({_at:new Date().toJSON(), _from: 'basesocket:onConnection', _type:'CLOG', about: `A socket is connecting from ${req.connection.remoteAddress}:${req.connection.remotePort}.`},'\n,')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // socket.isAlive = true
 | 
					      // socket.isAlive = true
 | 
				
			||||||
      // socket.on('pong', function() { this.isAlive = true })
 | 
					      // socket.on('pong', function() { this.isAlive = true })
 | 
				
			||||||
@ -26,9 +26,9 @@ module.exports = {
 | 
				
			|||||||
          if (dataObj?.skevent === 'PING') {
 | 
					          if (dataObj?.skevent === 'PING') {
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          console.log({ _at: new Date().toJSON(), _from: 'Socket:onMessage', _type: 'CLOG', usid: socket.usid, dataObj }, '\n,')
 | 
					          //console.log({ _at: new Date().toJSON(), _from: 'basesocket:onMessage', _type: 'CLOG', usid: socket.usid, skevent: dataObj?.skevent }, '\n,')
 | 
				
			||||||
        } catch (exception) {
 | 
					        } catch (exception) {
 | 
				
			||||||
          console.error({ _at: new Date().toJSON(), _from: 'Socket:onMessage', _type: 'CERROR', about: 'Unable to parse socket message', data }, '\n,')
 | 
					          console.error({ _at: new Date().toJSON(), _from: 'basesocket:onMessage', _type: 'CERROR', about: 'Unable to parse socket message', data }, '\n,')
 | 
				
			||||||
          return
 | 
					          return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (['SOCKET_OWNER', 'SOCKET_OWNER_RECONNECT'].includes(dataObj.skevent)) {
 | 
					        if (['SOCKET_OWNER', 'SOCKET_OWNER_RECONNECT'].includes(dataObj.skevent)) {
 | 
				
			||||||
@ -37,13 +37,13 @@ module.exports = {
 | 
				
			|||||||
          if (typeof dataObj._passtokenSource?.usid === 'string') {
 | 
					          if (typeof dataObj._passtokenSource?.usid === 'string') {
 | 
				
			||||||
            my.socketPool[dataObj._passtokenSource.usid] = socket
 | 
					            my.socketPool[dataObj._passtokenSource.usid] = socket
 | 
				
			||||||
            socket.usid = dataObj._passtokenSource.usid
 | 
					            socket.usid = dataObj._passtokenSource.usid
 | 
				
			||||||
            console.log({
 | 
					            // console.log({
 | 
				
			||||||
              _at: new Date().toJSON(), _from: 'Socket:onMessage', _type: 'CLOG',
 | 
					            //   _at: new Date().toJSON(), _from: 'basesocket:onMessage', _type: 'CLOG',
 | 
				
			||||||
              skevent: dataObj.skevent,
 | 
					            //   skevent: dataObj.skevent,
 | 
				
			||||||
              usid: dataObj._passtokenSource.usid,
 | 
					            //   usid: dataObj._passtokenSource.usid,
 | 
				
			||||||
              socketPool: Object.keys(my.socketPool)?.length,
 | 
					            //   socketPool: Object.keys(my.socketPool)?.length,
 | 
				
			||||||
              socketClients: my.wsServer.clients.size
 | 
					            //   socketClients: my.wsServer.clients.size
 | 
				
			||||||
            }, '\n,')
 | 
					            // }, '\n,')
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,7 +62,7 @@ module.exports = {
 | 
				
			|||||||
      // }, 60000)
 | 
					      // }, 60000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      socket.on('close', () => {
 | 
					      socket.on('close', () => {
 | 
				
			||||||
        //console.log({_at:new Date().toJSON(), _from: 'Socket:onClose', _type:'CLOG', usid: socket?.usid},'\n,') // don't know why, but this output happens too often without usid.
 | 
					        //console.log({_at:new Date().toJSON(), _from: 'basesocket:onClose', _type:'CLOG', usid: socket?.usid},'\n,') // don't know why, but this output happens too often without usid.
 | 
				
			||||||
        delete my.socketPool[socket?.usid]
 | 
					        delete my.socketPool[socket?.usid]
 | 
				
			||||||
        // clearInterval(heartbeat)
 | 
					        // clearInterval(heartbeat)
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user