logging method modify
This commit is contained in:
		
							parent
							
								
									d4a7836ef7
								
							
						
					
					
						commit
						3e7ee505b4
					
				| @ -143,13 +143,13 @@ type Socket interface { | ||||
| 
 | ||||
| func NewSocket(sb SocketBuilder, parentContext cuc.Context) (Socket, error) { | ||||
| 	if nil == sb { | ||||
| 		logging.Logger().Panic("Client Socket: SocketBuilder must be specified") | ||||
| 		logging.Logger().Panicf("Client Socket: SocketBuilder must be specified") | ||||
| 	} | ||||
| 	sb.Validate() | ||||
| 
 | ||||
| 	sc := sb.SocketContext(parentContext) | ||||
| 	if nil == sc { | ||||
| 		logging.Logger().Panic("Client Socket: SocketContext must be specified") | ||||
| 		logging.Logger().Panicf("Client Socket: SocketContext must be specified") | ||||
| 	} | ||||
| 
 | ||||
| 	sh := sb.GetSocketHandler() | ||||
|  | ||||
| @ -87,7 +87,7 @@ func (sb *SocketBuilders) GetWriteBufferSize() int { | ||||
| 
 | ||||
| func (sb *SocketBuilders) Validate() { | ||||
| 	if nil == sb.SocketHandler { | ||||
| 		logging.Logger().Panic("Websocket Fasthttp: SocketHandler must be specified") | ||||
| 		logging.Logger().Panicf("Websocket Fasthttp: SocketHandler must be specified") | ||||
| 	} | ||||
| 	sb.SocketHandler.Validate() | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										14
									
								
								server.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								server.go
									
									
									
									
									
								
							| @ -42,7 +42,7 @@ type server struct { | ||||
| 
 | ||||
| func (s *server) Start() error { | ||||
| 	if nil == s.sh { | ||||
| 		logging.Logger().Panic("Server: server handler must be specified.") | ||||
| 		logging.Logger().Panicf("Server: server handler must be specified.") | ||||
| 	} | ||||
| 	s.sh.Validate() | ||||
| 
 | ||||
| @ -92,7 +92,7 @@ func (s *server) Start() error { | ||||
| 
 | ||||
| func (s *server) Stop() { | ||||
| 	if s.stopChan == nil { | ||||
| 		logging.Logger().Warn("Server: server must be started before stopping it") | ||||
| 		logging.Logger().Warnf("Server: server must be started before stopping it") | ||||
| 		return | ||||
| 	} | ||||
| 	close(s.stopChan) | ||||
| @ -101,7 +101,7 @@ func (s *server) Stop() { | ||||
| 
 | ||||
| 	s.sh.OnStop(s.ctx) | ||||
| 
 | ||||
| 	logging.Logger().Info(fmt.Sprintf("Server[%s] is stopped", s.sh.GetName())) | ||||
| 	logging.Logger().Infof("Server[%s] is stopped", s.sh.GetName()) | ||||
| } | ||||
| 
 | ||||
| func (s *server) Context() ServerContext { | ||||
| @ -114,11 +114,11 @@ func handleServer(s *server) { | ||||
| 		defer s.stopWg.Done() | ||||
| 
 | ||||
| 		if err := s.httpServer.Serve(s.listener); nil != err { | ||||
| 			logging.Logger().Error(fmt.Sprintf("Server: Server err - %v", err)) | ||||
| 			logging.Logger().Errorf("Server: Server err - %v", err) | ||||
| 		} | ||||
| 	}() | ||||
| 
 | ||||
| 	logging.Logger().Info(fmt.Sprintf("Server[%s] is started", s.sh.GetName())) | ||||
| 	logging.Logger().Infof("Server[%s] is started", s.sh.GetName()) | ||||
| 	s.sh.OnStart(s.ctx) | ||||
| 
 | ||||
| 	select { | ||||
| @ -154,7 +154,7 @@ func (s *server) handleRequest(ctx *fasthttp.RequestCtx) { | ||||
| 		} | ||||
| 
 | ||||
| 		soc := newSocket(socketHandler, socketCTX, conn, socketID) | ||||
| 		logging.Logger().Debug(fmt.Sprintf("Server: Client[%s] is connected.", soc.RemoteAddr())) | ||||
| 		logging.Logger().Debugf("Server: Client[%s] is connected.", soc.RemoteAddr()) | ||||
| 
 | ||||
| 		socketHandler.addSocket(soc) | ||||
| 		socketHandler.OnConnect(soc) | ||||
| @ -186,7 +186,7 @@ func handleConnection(s *server, soc Socket, socketHandler SocketHandler) { | ||||
| 	case <-handleDoneChan: | ||||
| 		close(clientStopChan) | ||||
| 		socketHandler.OnDisconnect(soc) | ||||
| 		logging.Logger().Debug(fmt.Sprintf("Server: Client[%s] is disconnected.", soc.RemoteAddr())) | ||||
| 		logging.Logger().Debugf("Server: Client[%s] is disconnected.", soc.RemoteAddr()) | ||||
| 		socketHandler.removeSocket(soc) | ||||
| 		soc.Close() | ||||
| 	} | ||||
|  | ||||
| @ -86,7 +86,7 @@ func (sh *ServerHandlers) CheckOrigin(ctx *fasthttp.RequestCtx) bool { | ||||
| } | ||||
| 
 | ||||
| func (sh *ServerHandlers) OnError(serverCTX ServerContext, ctx *fasthttp.RequestCtx, status int, reason error) { | ||||
| 	logging.Logger().Error(fmt.Sprintf("Server: error status: %d, reason: %v, [%v]", status, reason, ctx)) | ||||
| 	logging.Logger().Errorf("Server: error status: %d, reason: %v, [%v]", status, reason, ctx) | ||||
| } | ||||
| 
 | ||||
| // OnStop invoked when server is stopped | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user