@@ -100,7 +100,7 @@ func (e *RemoteExecute) receiveAndHandle(
100100 for {
101101 select {
102102 case <- ctx .streamCtx .Done ():
103- log .Infof ("agent(key: %s) stream context done, err: %v" , ctx .key , ctx .streamCtx .Err ())
103+ log .Infof ("[REMOTE_EXEC] agent(key: %s) stream context done, err: %v" , ctx .key , ctx .streamCtx .Err ())
104104 return
105105 case <- agentInactivityTimer .C :
106106 e .handleAgentInactivityTimeout (ctx )
@@ -178,15 +178,15 @@ func (e *RemoteExecute) handleResponse(ctx *remoteExecContext, resp *api.RemoteE
178178
179179 cmdRespMng := ctx .cmdMng .GetRespManager (* resp .RequestId )
180180 if ! cmdRespMng .IsValid () {
181- log .Errorf ("[REMOTE_EXEC] agent(key: %s, request id : %v ) response manager not found" , ctx .key , resp .RequestId )
181+ log .Errorf ("[REMOTE_EXEC] agent(key: %s, request_id : %d ) response manager not found" , ctx .key , resp .GetRequestId () )
182182 return
183183 }
184184
185185 e .logResponse (resp , ctx .key )
186186
187187 switch {
188188 case resp .Errmsg != nil :
189- log .Errorf ("[REMOTE_EXEC] agent(key: %s, request id : %v ) run command error: %s" , ctx .key , * resp .RequestId , * resp .Errmsg )
189+ log .Errorf ("[REMOTE_EXEC] agent(key: %s, request_id : %d ) run command error: %s" , ctx .key , resp .GetRequestId () , * resp .Errmsg )
190190 cmdRespMng .SetErrorMessage (* resp .Errmsg )
191191
192192 result := resp .CommandResult
@@ -211,7 +211,7 @@ func (e *RemoteExecute) handleResponse(ctx *remoteExecContext, resp *api.RemoteE
211211 cmdRespMng .GetRemoteCommandsDoneChan <- struct {}{}
212212 return
213213 default :
214- log .Infof ("[REMOTE_EXEC] agent(key: %s, request id : %v ) responsed default" , ctx .key , * resp .RequestId )
214+ log .Infof ("[REMOTE_EXEC] agent(key: %s, request_id : %d ) responsed default" , ctx .key , resp .GetRequestId () )
215215 result := resp .CommandResult
216216 if result == nil {
217217 return
@@ -254,11 +254,10 @@ func (e *RemoteExecute) waitAndSend(
254254 return err
255255 case req , ok := <- ctx .cmdMng .RequestChan :
256256 if ! ok {
257- err := fmt .Errorf ("[REMOTE_EXEC] agent(key: %s) cmd manager request channel has been closed" , ctx .key )
257+ err := fmt .Errorf ("[REMOTE_EXEC] agent(key: %s) RequestChan has been closed" , ctx .key )
258258 log .Error (err )
259259 return err
260260 }
261- log .Infof ("[REMOTE_EXEC] agent(key: %s) received request from RequestChan, request_id: %v" , ctx .key , req .RequestId )
262261 if err := e .sendRequest (ctx , stream , req ); err != nil {
263262 return err
264263 }
@@ -341,14 +340,25 @@ func (e *RemoteExecute) sendRequest(ctx *remoteExecContext, stream api.Synchroni
341340}
342341
343342func (e * RemoteExecute ) logResponse (resp * api.RemoteExecResponse , key string ) {
343+ if resp .GetCommandResult () != nil {
344+ log .Infof ("[REMOTE_EXEC] get response from agent(key: %s), request_id: %d, MD5: %s, total_len: %d" , key , resp .GetRequestId (), resp .GetCommandResult ().GetMd5 (), resp .GetCommandResult ().GetTotalLen ())
345+ } else {
346+ log .Infof ("[REMOTE_EXEC] get response from agent(key: %s), request_id: %d" , key , resp .GetRequestId ())
347+ }
344348 b , _ := json .Marshal (resp )
345- log .Infof ("[REMOTE_EXEC] agent(key: %s) response : %s" , key , string (b ))
349+ log .Debugf ("[REMOTE_EXEC] get response from agent(key: %s), request_id : %d: % s" , key , resp . GetRequestId () , string (b ))
346350}
347351
348352func (e * RemoteExecute ) logRequest (ctx * remoteExecContext , req * api.RemoteExecRequest ) {
349353 if req .RequestId != nil && * req .RequestId == reqeustIDOfResponseToHeartbeat {
350354 return
351355 }
356+ if req .GetCommandData () != nil {
357+ log .Infof ("[REMOTE_EXEC] send request to agent(key: %s), request_id: %d, exec_type: %s, batch_len: %d, MD5: %s, total_len: %d" , ctx .key , req .GetRequestId (), req .GetExecType (), req .GetBatchLen (), req .GetCommandData ().GetMd5 (), req .GetCommandData ().GetTotalLen ())
358+ } else {
359+ log .Infof ("[REMOTE_EXEC] send request to agent(key: %s), request_id: %d, exec_type: %s, batch_len: %d" , ctx .key , req .GetRequestId (), req .GetExecType (), req .GetBatchLen ())
360+ }
361+
352362 b , _ := json .Marshal (req )
353- log .Infof ("[REMOTE_EXEC] request to agent(key: %s): %s" , ctx .key , string (b ))
363+ log .Debugf ("[REMOTE_EXEC] send request to agent(key: %s), request_id : %d: % s" , ctx .key , req . GetRequestId () , string (b ))
354364}
0 commit comments