From 051c9581ea354dbc4c8d0fd36d9df64dc599326e Mon Sep 17 00:00:00 2001 From: John Date: Fri, 31 Aug 2018 23:53:57 +0800 Subject: [PATCH] =?UTF-8?q?websocket=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/net/ghttp/ghttp_server.go | 4 ++-- g/net/ghttp/ghttp_server_websocket.go | 24 +++++++++++++++++++++++- g/os/glog/glog_logger.go | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/g/net/ghttp/ghttp_server.go b/g/net/ghttp/ghttp_server.go index b2052fadc..5553bdd6b 100644 --- a/g/net/ghttp/ghttp_server.go +++ b/g/net/ghttp/ghttp_server.go @@ -204,8 +204,8 @@ func GetServer(name...interface{}) (*Server) { nameToUriType : gtype.NewInt(), gzipMimesMap : make(map[string]struct{}), } - s.errorLogger.SetBacktraceSkip(1) - s.accessLogger.SetBacktraceSkip(1) + //s.errorLogger.SetBacktraceSkip(1) + //s.accessLogger.SetBacktraceSkip(1) // 设置路由解析缓存上限,使用LRU进行缓存淘汰 s.serveCache.SetCap(gSERVE_CACHE_LRU_SIZE) s.hooksCache.SetCap(gHOOKS_CACHE_LRU_SIZE) diff --git a/g/net/ghttp/ghttp_server_websocket.go b/g/net/ghttp/ghttp_server_websocket.go index b40096aa9..f1bf09287 100644 --- a/g/net/ghttp/ghttp_server_websocket.go +++ b/g/net/ghttp/ghttp_server_websocket.go @@ -11,4 +11,26 @@ import "github.com/gorilla/websocket" type WebSocket struct { *websocket.Conn -} \ No newline at end of file +} + +const ( + // TextMessage denotes a text data message. The text message payload is + // interpreted as UTF-8 encoded text data. + WS_MSG_TEXT = websocket.TextMessage + + // BinaryMessage denotes a binary data message. + WS_MSG_BINARY = websocket.BinaryMessage + + // CloseMessage denotes a close control message. The optional message + // payload contains a numeric code and text. Use the FormatCloseMessage + // function to format a close message payload. + WS_MSG_CLOSE = websocket.CloseMessage + + // PingMessage denotes a ping control message. The optional message payload + // is UTF-8 encoded text. + WS_MSG_PING = websocket.PingMessage + + // PongMessage denotes a pong control message. The optional message payload + // is UTF-8 encoded text. + WS_MSG_PONG = websocket.PongMessage +) \ No newline at end of file diff --git a/g/os/glog/glog_logger.go b/g/os/glog/glog_logger.go index 12bbeca20..1b5b9ca66 100644 --- a/g/os/glog/glog_logger.go +++ b/g/os/glog/glog_logger.go @@ -169,7 +169,7 @@ func (l *Logger) stdPrint(s string) { func (l *Logger) errPrint(s string) { // 记录调用回溯信息 if l.btEnabled.Val() { - backtrace := l.GetBacktrace(2) + backtrace := l.GetBacktrace(3) if s[len(s) - 1] == byte('\n') { s = s + backtrace + ln } else { @@ -199,7 +199,7 @@ func (l *Logger) GetBacktrace(skip...int) string { for i := 1; i < 10000; i++ { if _, cfile, cline, ok := runtime.Caller(customSkip + i + l.btSkip.Val()); ok { // 不打印出go源码路径 - if !gregex.IsMatchString("^" + gfile.GoRootOfBuild(), cfile) { + if !gregex.IsMatchString("^" + gfile.GoRootOfBuild(), cfile) && !gregex.IsMatchString(``, cfile) { backtrace += strconv.Itoa(index) + ".\t" + cfile + ":" + strconv.Itoa(cline) + ln index++ }