diff --git a/glide.yaml b/glide.yaml index 4625fd5..88d38f8 100644 --- a/glide.yaml +++ b/glide.yaml @@ -17,4 +17,3 @@ import: - package: git.loafle.net/commons_go/util subpackages: - channel -- package: git.loafle.net/commons_go/logging diff --git a/protocol/jsonrpc/handler.go b/protocol/jsonrpc/handler.go index 945c240..4f17cc3 100644 --- a/protocol/jsonrpc/handler.go +++ b/protocol/jsonrpc/handler.go @@ -4,10 +4,8 @@ import ( "context" "encoding/json" "io" + "log" - "go.uber.org/zap" - - "git.loafle.net/commons_go/logging" gws "git.loafle.net/overflow/overflow_gateway_websocket" ) @@ -16,16 +14,14 @@ type MessageHandler interface { } type messageHandler struct { - ctx context.Context - logger *zap.Logger - o *Options + ctx context.Context + o *Options } func NewHandler(ctx context.Context, o *Options) MessageHandler { h := &messageHandler{ - ctx: ctx, - logger: logging.WithContext(ctx), - o: o, + ctx: ctx, + o: o, } return h @@ -62,7 +58,7 @@ func (h *messageHandler) onRequest(soc gws.Socket, req *ServerRequest) []byte { j, err := json.Marshal(res) if nil != err { - h.logger.Error("JSON RPC error", zap.Any("err", err)) + log.Printf("JSON RPC error: %v", err) } return j @@ -71,6 +67,6 @@ func (h *messageHandler) onRequest(soc gws.Socket, req *ServerRequest) []byte { func (h *messageHandler) onNotify(soc gws.Socket, req *ServerRequest) { err := h.o.OnNotify(soc, req.Method, req.Params) if nil != err { - h.logger.Error("JSON RPC error", zap.Any("err", err)) + log.Printf("JSON RPC error: %v", err) } } diff --git a/server.go b/server.go index 0528fa2..4d14946 100644 --- a/server.go +++ b/server.go @@ -4,9 +4,6 @@ import ( "context" "net/http" - "go.uber.org/zap" - - "git.loafle.net/commons_go/logging" channelUtil "git.loafle.net/commons_go/util/channel" "git.loafle.net/overflow/overflow_gateway_websocket/websocket" "github.com/valyala/fasthttp" @@ -26,7 +23,6 @@ type Server interface { type server struct { _ctx context.Context - _logger *zap.Logger _option *ServerOptions _upgrader *websocket.Upgrader _handlers map[string]*SocketOptions @@ -37,7 +33,6 @@ type server struct { func NewServer(ctx context.Context, o *ServerOptions) Server { s := &server{ _ctx: ctx, - _logger: logging.WithContext(ctx), _option: o.Validate(), _handlers: make(map[string]*SocketOptions, 1), _sockets: make(map[string]Socket, 100), @@ -110,7 +105,6 @@ func (s *server) listenHandler() { for { select { case <-s._ctx.Done(): - s._logger.Info("websocket server: Context Done") return case ca := <-s._socketsCh: switch ca.Type { diff --git a/socket.go b/socket.go index 1e98aa1..20f73c1 100644 --- a/socket.go +++ b/socket.go @@ -3,11 +3,9 @@ package overflow_gateway_websocket import ( "context" "io" + "log" "time" - "go.uber.org/zap" - - "git.loafle.net/commons_go/logging" "git.loafle.net/overflow/overflow_gateway_websocket/websocket" ) @@ -21,7 +19,6 @@ type Socket interface { type socket struct { ctx context.Context - logger *zap.Logger id string o *SocketOptions conn *websocket.Conn @@ -34,7 +31,6 @@ type socket struct { func NewSocket(ctx context.Context, id string, path string, o *SocketOptions, conn *websocket.Conn) Socket { c := &socket{ ctx: ctx, - logger: logging.WithContext(ctx), id: id, o: o, conn: conn, @@ -112,12 +108,12 @@ func (soc *socket) listenWrite() { case w := <-soc.writeCh: if writeTimeout := soc.o.WriteTimeout; writeTimeout > 0 { err := soc.conn.SetWriteDeadline(time.Now().Add(writeTimeout)) - soc.logger.Error("Socket timeout", zap.Any("err", err)) + log.Printf("Socket timeout: %v", err) } err := soc.conn.WriteMessage(soc.messageType, w) if nil != err { - soc.logger.Error("Socket Write error", zap.Any("err", err)) + log.Printf("Socket Write error: %v", err) } // receive done request