Browse Source

优化日志输出

pull/62/head
JeshuaRen 2 months ago
parent
commit
bfee415471
2 changed files with 11 additions and 3 deletions
  1. +3
    -3
      sdks/pcmscheduler/jobmgr.go
  2. +8
    -0
      utils/serder/serder.go

+ 3
- 3
sdks/pcmscheduler/jobmgr.go View File

@@ -238,9 +238,6 @@ func (c *Client) QueryAITrainLog(req QueryAITrainLogReq, token string) (*QueryAI
return nil, err
}

//req.AdapterID = "1777144940459986944"
//req.InstanceNum = "0"

resp, err := http2.GetJSON(targetUrl, http2.RequestParam{
Query: req,
Header: map[string]string{
@@ -251,6 +248,9 @@ func (c *Client) QueryAITrainLog(req QueryAITrainLogReq, token string) (*QueryAI
return nil, err
}

//all, err := io.ReadAll(resp.Body)
//println(string(all))

contType := resp.Header.Get("Content-Type")
if strings.Contains(contType, http2.ContentTypeJSON) {
var codeResp response[QueryAITrainLogResp]


+ 8
- 0
utils/serder/serder.go View File

@@ -97,6 +97,14 @@ func ObjectToJSON(obj any) ([]byte, error) {
return json.Marshal(obj)
}

func ObjectToJSONString(obj any) string {
marshal, err := json.Marshal(obj)
if err != nil {
return err.Error()
}
return string(marshal)
}

// 将对象转为JSON字符串。如果需要支持解析TypeUnion类型,则使用"Ex"结尾的同名函数。
func ObjectToJSONStream(obj any) io.ReadCloser {
pr, pw := io.Pipe()


Loading…
Cancel
Save