mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化日志
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/duanhf2012/origin/v2/service"
|
"github.com/duanhf2012/origin/v2/service"
|
||||||
"github.com/duanhf2012/origin/v2/util/bytespool"
|
"github.com/duanhf2012/origin/v2/util/bytespool"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -140,10 +139,7 @@ func (slf *Client) GetId() string {
|
|||||||
func (slf *Client) Run() {
|
func (slf *Client) Run() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
buf := make([]byte, 4096)
|
log.StackError(fmt.Sprint(r))
|
||||||
l := runtime.Stack(buf, false)
|
|
||||||
errString := fmt.Sprint(r)
|
|
||||||
log.Dump(string(buf[:l]), log.String("error", errString))
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -156,7 +152,7 @@ func (slf *Client) Run() {
|
|||||||
slf.tcpConn.SetReadDeadline(slf.tcpService.tcpServer.ReadDeadline)
|
slf.tcpConn.SetReadDeadline(slf.tcpService.tcpServer.ReadDeadline)
|
||||||
bytes, err := slf.tcpConn.ReadMsg()
|
bytes, err := slf.tcpConn.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("read client failed", log.ErrorAttr("error", err), log.String("clientId", slf.id))
|
log.Debug("read client failed", log.ErrorField("error", err), log.String("clientId", slf.id))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
data, err := slf.tcpService.process.Unmarshal(slf.id, bytes)
|
data, err := slf.tcpService.process.Unmarshal(slf.id, bytes)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func (slf *WSClient) Run() {
|
|||||||
for {
|
for {
|
||||||
bytes, err := slf.wsConn.ReadMsg()
|
bytes, err := slf.wsConn.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("read client id %s is error:%+v", slf.id, err)
|
log.Debugf("read client id %s is error:%+v", slf.id, err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
data, err := slf.wsService.process.Unmarshal(slf.id, bytes)
|
data, err := slf.wsService.process.Unmarshal(slf.id, bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user