From 63f2fd2f07dc331f2b71222b528bea406421578d Mon Sep 17 00:00:00 2001 From: lejianwen <84855512@qq.com> Date: Thu, 2 Jan 2025 21:49:37 +0800 Subject: [PATCH] style(server): fmt print to log --- http/controller/admin/rustdesk.go | 2 +- service/serverCmd.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/http/controller/admin/rustdesk.go b/http/controller/admin/rustdesk.go index 9528a17..c8afdb6 100644 --- a/http/controller/admin/rustdesk.go +++ b/http/controller/admin/rustdesk.go @@ -103,7 +103,7 @@ func (r *Rustdesk) SendCmd(c *gin.Context) { rc := &RustdeskCmd{} c.ShouldBindJSON(rc) if rc.Cmd == "" { - response.Fail(c, 101, "cmd is required") + response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")) return } res, err := service.AllService.ServerCmdService.SendCmd(rc.Cmd, rc.Option) diff --git a/service/serverCmd.go b/service/serverCmd.go index 621c9b6..02e45b1 100644 --- a/service/serverCmd.go +++ b/service/serverCmd.go @@ -3,7 +3,6 @@ package service import ( "Gwen/global" "Gwen/model" - "fmt" "net" "time" ) @@ -66,14 +65,14 @@ func (is *ServerCmdService) SendSocketCmd(ty string, cmd string) (string, error) } conn, err := net.Dial(tcp, addr+":21115") if err != nil { - fmt.Printf("connect to id %s server failed: %v\n", ty, err) + global.Logger.Debugf("%s connect to id server failed: %v", ty, err) return "", err } defer conn.Close() //发送命令 _, err = conn.Write([]byte(cmd)) if err != nil { - fmt.Printf("send cmd failed: %v\n", err) + global.Logger.Debugf("%s send cmd failed: %v", ty, err) return "", err } time.Sleep(100 * time.Millisecond) @@ -81,7 +80,7 @@ func (is *ServerCmdService) SendSocketCmd(ty string, cmd string) (string, error) buf := make([]byte, 1024) n, err := conn.Read(buf) if err != nil && err.Error() != "EOF" { - fmt.Printf("read response failed: %v\n", err) + global.Logger.Debugf("%s read response failed: %v", ty, err) return "", err } return string(buf[:n]), nil