diff --git a/client/client.go b/client/client.go index 0466202..d04eb58 100644 --- a/client/client.go +++ b/client/client.go @@ -67,7 +67,7 @@ func (c *client) Connect() error { c.ctx = c.ch.ClientContext(nil) if err := c.ch.Init(c.ctx); nil != err { - logging.Logger().Panic(fmt.Sprintf("RPC Client: Initialization of client has been failed %v", err)) + logging.Logger().Panicf("RPC Client: Initialization of client has been failed %v", err) } if c.conn, err = c.rwcHandler.Connect(c.ctx); nil != err { @@ -84,7 +84,7 @@ func (c *client) Connect() error { func (c *client) Close() { if c.stopChan == nil { - logging.Logger().Warn("RPC Client: the client must be started before stopping it") + logging.Logger().Warnf("RPC Client: the client must be started before stopping it") return } @@ -94,7 +94,7 @@ func (c *client) Close() { c.stopWg.Wait() c.stopChan = nil - logging.Logger().Info(fmt.Sprintf("RPC Client: stopped")) + logging.Logger().Infof("RPC Client: stopped") } func (c *client) Send(method string, args ...interface{}) (err error) { @@ -310,7 +310,7 @@ func (c *client) rpcWriter(stopChan <-chan struct{}, writerDone chan<- error) { } if nil != err { if err == io.ErrUnexpectedEOF || err == io.EOF { - logging.Logger().Info("Client: disconnected from server") + logging.Logger().Infof("Client: disconnected from server") return } @@ -340,7 +340,7 @@ func (c *client) rpcReader(readerDone chan<- error) { resCodec, err := c.rwcHandler.ReadResponse(c.ctx, c.ch.GetCodec(), c.conn) if nil != err { if err == io.ErrUnexpectedEOF || err == io.EOF { - logging.Logger().Info("Client: disconnected from server") + logging.Logger().Infof("Client: disconnected from server") return } err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err) diff --git a/client/client_handlers.go b/client/client_handlers.go index da29d24..f586f3f 100644 --- a/client/client_handlers.go +++ b/client/client_handlers.go @@ -71,7 +71,7 @@ func (ch *ClientHandlers) GetRequestID() uint64 { func (ch *ClientHandlers) Validate() { if nil == ch.Codec { - logging.Logger().Panic("RPC Client Handler: Codec must be specified") + logging.Logger().Panicf("RPC Client Handler: Codec must be specified") } if ch.RequestTimeout <= 0 { diff --git a/client/rwc/socket/client_rwc_handlers.go b/client/rwc/socket/client_rwc_handlers.go index d9595a0..e9f25f1 100644 --- a/client/rwc/socket/client_rwc_handlers.go +++ b/client/rwc/socket/client_rwc_handlers.go @@ -50,6 +50,6 @@ func (crwch *ClientReadWriteCloseHandlers) Validate() { crwch.ClientReadWriteCloseHandlers.Validate() if nil == crwch.SocketBuilder { - logging.Logger().Panic("RPC Client: SocketBuilder must be specified") + logging.Logger().Panicf("RPC Client: SocketBuilder must be specified") } } diff --git a/client/rwc/websocket/fasthttp/client_rwc_handlers.go b/client/rwc/websocket/fasthttp/client_rwc_handlers.go index 9053dd9..9401be2 100644 --- a/client/rwc/websocket/fasthttp/client_rwc_handlers.go +++ b/client/rwc/websocket/fasthttp/client_rwc_handlers.go @@ -61,7 +61,7 @@ func (crwch *ClientReadWriteCloseHandlers) Validate() { crwch.ClientReadWriteCloseHandlers.Validate() if nil == crwch.SocketBuilder { - logging.Logger().Panic("RPC Client: SocketBuilder must be specified") + logging.Logger().Panicf("RPC Client: SocketBuilder must be specified") } } diff --git a/server/servlet_handlers.go b/server/servlet_handlers.go index 87577e2..7696a46 100644 --- a/server/servlet_handlers.go +++ b/server/servlet_handlers.go @@ -23,9 +23,9 @@ func (sh *ServletHandlers) Invoke(servletCTX rpc.ServletContext, requestCodec pr result, err = sh.RPCInvoker.Invoke(requestCodec) if nil != err { if params, pErr := requestCodec.Params(); nil != err { - logging.Logger().Error(fmt.Sprintf("RPC Servlet Handler: Read Param of Method[%s] returns error %v", requestCodec.Method(), pErr)) + logging.Logger().Errorf("RPC Servlet Handler: Read Param of Method[%s] returns error %v", requestCodec.Method(), pErr) } else { - logging.Logger().Error(fmt.Sprintf("RPC Servlet Handler: Method[%s] params[%v] returns error %v", requestCodec.Method(), params, err)) + logging.Logger().Errorf("RPC Servlet Handler: Method[%s] params[%v] returns error %v", requestCodec.Method(), params, err) } } @@ -40,6 +40,6 @@ func (sh *ServletHandlers) Validate() { sh.ServletHandlers.Validate() if nil == sh.RPCInvoker { - logging.Logger().Panic(fmt.Sprintf("RPC Servlet Handler: RPC Invoker must be specified")) + logging.Logger().Panicf("RPC Servlet Handler: RPC Invoker must be specified") } } diff --git a/servlet.go b/servlet.go index 91f728d..100ea75 100644 --- a/servlet.go +++ b/servlet.go @@ -72,7 +72,7 @@ func (s *rpcServlet) Start(parentCTX cuc.Context, conn interface{}, doneChan cha s.serverCodec = sc if err := s.sh.Init(s.ctx); nil != err { - logging.Logger().Panic(fmt.Sprintf("Servlet: Initialization of servlet has been failed %v", err)) + logging.Logger().Panicf("Servlet: Initialization of servlet has been failed %v", err) } s.responseQueueChan = make(chan *responseState, s.sh.GetPendingResponses()) @@ -100,7 +100,7 @@ func (s *rpcServlet) Send(method string, args ...interface{}) (err error) { func (s *rpcServlet) 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) @@ -113,13 +113,13 @@ func (s *rpcServlet) Stop() { s.conn = nil s.serverCodec = nil - logging.Logger().Info(fmt.Sprintf("Servlet is stopped")) + logging.Logger().Infof("Servlet is stopped") } func handleServlet(s *rpcServlet) { var err error - logging.Logger().Info(fmt.Sprintf("Servlet is started")) + logging.Logger().Infof("Servlet is started") defer func() { s.stopWg.Done() @@ -148,16 +148,16 @@ func handleServlet(s *rpcServlet) { } if err != nil { - logging.Logger().Error(fmt.Sprintf("RPC Server: servlet error %v", err)) + logging.Logger().Errorf("RPC Server: servlet error %v", err) } } func handleReader(s *rpcServlet, stopChan chan struct{}, doneChan chan error) { - logging.Logger().Debug(fmt.Sprintf("reader of Servlet is started")) + logging.Logger().Debugf("reader of Servlet is started") var err error defer func() { - logging.Logger().Debug(fmt.Sprintf("reader of Servlet is stopped")) + logging.Logger().Debugf("reader of Servlet is stopped") if r := recover(); r != nil { if err == nil { @@ -179,7 +179,7 @@ func handleReader(s *rpcServlet, stopChan chan struct{}, doneChan chan error) { err = fmt.Errorf("RPC Server: disconnected from client") return } - logging.Logger().Error(fmt.Sprintf("RPC Server: Cannot read request: [%s]", err)) + logging.Logger().Errorf("RPC Server: Cannot read request: [%s]", err) continue } @@ -196,11 +196,11 @@ func handleReader(s *rpcServlet, stopChan chan struct{}, doneChan chan error) { } func handleWriter(s *rpcServlet, stopChan chan struct{}, doneChan chan error) { - logging.Logger().Debug(fmt.Sprintf("writer of Servlet is started")) + logging.Logger().Debugf("writer of Servlet is started") var err error defer func() { - logging.Logger().Debug(fmt.Sprintf("writer of Servlet is stopped")) + logging.Logger().Debugf("writer of Servlet is stopped") if r := recover(); r != nil { if err == nil { err = fmt.Errorf("RPC Server: Panic when writing response to client: %v", r) @@ -233,11 +233,11 @@ func handleWriter(s *rpcServlet, stopChan chan struct{}, doneChan chan error) { if nil != rs.requestCodec { if err := s.rwcSH.WriteResponse(s.ctx, s.conn, rs.requestCodec, rs.result, rs.err); nil != err { - logging.Logger().Error(fmt.Sprintf("RPC Server: response error %v", err)) + logging.Logger().Errorf("RPC Server: response error %v", err) } } else { if err := s.rwcSH.WriteNotification(s.ctx, s.conn, s.serverCodec, rs.noti.method, rs.noti.args); nil != err { - logging.Logger().Error(fmt.Sprintf("RPC Server: notification error %v", err)) + logging.Logger().Errorf("RPC Server: notification error %v", err) } }