diff --git a/database/main.go b/database/main.go index 1351ba9..247b08c 100644 --- a/database/main.go +++ b/database/main.go @@ -8,7 +8,7 @@ import ( _ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/sqlite" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" ) // Write Database connection for writing purposes diff --git a/websocket/client.go b/websocket/client.go index cfe1c6e..4ee9afb 100644 --- a/websocket/client.go +++ b/websocket/client.go @@ -2,7 +2,7 @@ package websocket import ( "github.com/google/uuid" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" "github.com/gorilla/websocket" ) @@ -22,7 +22,7 @@ type Client struct { // NewClient by websocket func NewClient(s *Server, ws *websocket.Conn) *Client { if ws == nil { - log.Panic("ws cannot be nil") + log.WithField("modul", "websocket").Panic("client cannot be created without websocket") } return &Client{ server: s, @@ -56,7 +56,7 @@ func (c *Client) Write(msg *Message) { func (c *Client) Close() { c.writeQuit <- true c.readQuit <- true - log.Info("client disconnecting...", c.GetID()) + log.WithField("modul", "websocket").Info("client disconnecting...", c.GetID()) } // Listen write and read request via channel @@ -76,7 +76,7 @@ func (c *Client) handleInput(msg *Message) { msg.server = c.server c.server.msgChanIn <- msg } else { - log.Println("no valid msg for:", c.GetID(), "error:", err, "\nmessage:", msg) + log.WithField("modul", "websocket").Println("no valid msg for:", c.GetID(), "error:", err, "\nmessage:", msg) } } @@ -112,7 +112,7 @@ func (c *Client) listenRead() { if websocket.IsCloseError(err, websocket.CloseGoingAway) { return } else if err != nil { - log.Infof("error on reading %s: %s", c.GetID(), err) + log.WithField("modul", "websocket").Warnf("error on reading %s: %s", c.GetID(), err) return } else { c.handleInput(&msg) diff --git a/websocket/server.go b/websocket/server.go index ec77035..237bf59 100644 --- a/websocket/server.go +++ b/websocket/server.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/gorilla/websocket" - log "github.com/sirupsen/logrus" + "github.com/bdlm/log" ) // Server of websocket @@ -34,7 +34,7 @@ func NewServer(msgChanIn chan *Message, sessionManager *SessionManager) *Server func (s *Server) Handler(w http.ResponseWriter, r *http.Request) { conn, err := s.upgrader.Upgrade(w, r, nil) if err != nil { - log.Info(err) + log.WithField("modul", "websocket").Warnf("error during upgrade to websocket: %s", err) return } client := NewClient(s, conn)