🎨 logging

This commit is contained in:
Daniel 2023-06-02 22:26:01 +08:00
parent 8658f3edfc
commit 156fc97c54
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -373,11 +373,11 @@ func serveWebSocket(ginServer *gin.Engine) {
})
util.WebSocketServer.HandlePong(func(session *melody.Session) {
//logging.LogInfof("pong")
logging.LogInfof("pong")
})
util.WebSocketServer.HandleConnect(func(s *melody.Session) {
//logging.LogInfof("ws check auth for [%s]", s.Request.RequestURI)
logging.LogInfof("ws check auth for [%s]", s.Request.RequestURI)
authOk := true
if "" != model.Conf.AccessAuthCode {
@ -410,29 +410,29 @@ func serveWebSocket(ginServer *gin.Engine) {
if !authOk {
s.CloseWithMsg([]byte(" unauthenticated"))
//logging.LogWarnf("closed an unauthenticated session [%s]", util.GetRemoteAddr(s))
logging.LogWarnf("closed an unauthenticated session [%s]", util.GetRemoteAddr(s))
return
}
util.AddPushChan(s)
//sessionId, _ := s.Get("id")
//logging.LogInfof("ws [%s] connected", sessionId)
sessionId, _ := s.Get("id")
logging.LogInfof("ws [%s] connected", sessionId)
})
util.WebSocketServer.HandleDisconnect(func(s *melody.Session) {
util.RemovePushChan(s)
//sessionId, _ := s.Get("id")
//logging.LogInfof("ws [%s] disconnected", sessionId)
sessionId, _ := s.Get("id")
logging.LogInfof("ws [%s] disconnected", sessionId)
})
util.WebSocketServer.HandleError(func(s *melody.Session, err error) {
//sessionId, _ := s.Get("id")
//logging.LogDebugf("ws [%s] failed: %s", sessionId, err)
sessionId, _ := s.Get("id")
logging.LogDebugf("ws [%s] failed: %s", sessionId, err)
})
util.WebSocketServer.HandleClose(func(s *melody.Session, i int, str string) error {
//sessionId, _ := s.Get("id")
//logging.LogDebugf("ws [%s] closed: %v, %v", sessionId, i, str)
sessionId, _ := s.Get("id")
logging.LogDebugf("ws [%s] closed: %v, %v", sessionId, i, str)
return nil
})