Commit 09c3af54 by Joneq

完善json记录

parent 3ce9c71b
......@@ -2,4 +2,8 @@ module go-websocket
go 1.15
require github.com/gogf/gf/v2 v2.0.6
require (
github.com/gogf/gf v1.16.9
github.com/gogf/gf/v2 v2.1.4
github.com/longbridgeapp/sqlparser v0.3.1 // indirect
)
package main
import (
"go-websocket/internal/logic/websocket_logic"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
......@@ -9,6 +11,11 @@ import (
)
func main() {
websocket_logic.WriteLog()
panic(1)
s := g.Server()
s.BindHandler("/ws", func(r *ghttp.Request) {
var ctx = r.Context()
......
package websocket_logic
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)
//公公层
func WriteLog() {
WriteJsonLog()
}
func WriteJsonLog() {
ctx := context.TODO()
g.Log().Debug(ctx, g.Map{"uid": 100, "name": "john"})
type User struct {
Uid int `json:"uid"`
Name string `json:"name"`
}
g.Log().Debug(ctx, User{100, "john"})
}
2022-09-20 17:33:01.270 [DEBU] {"name":"john","uid":100}
2022-09-20 17:33:01.270 [DEBU] {"uid":100,"name":"john"}
2022-09-20 17:43:22.537 [DEBU] {"name":"john","uid":100}
2022-09-20 17:43:22.537 [DEBU] {"uid":100,"name":"john"}
2022-09-20 17:47:01.329 [DEBU] {"name":"john","uid":100}
2022-09-20 17:47:01.329 [DEBU] {"uid":100,"name":"john"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment