@@ -83,7 +83,7 @@ func (s *AgentService) RegisterAgent(ctx context.Context, req *AgentRequest) (*A
8383 Key : oldAgent .AgentKey ,
8484 }, nil
8585 } else {
86- catcher .Error ("agent already exists" , err , map [string ]any {"hostname" : agent .Hostname })
86+ catcher .Error ("agent already exists" , err , map [string ]any {"hostname" : agent .Hostname , "process" : "agent-manager" })
8787 return nil , status .Errorf (codes .AlreadyExists , "hostname has already been registered" )
8888 }
8989 }
@@ -92,7 +92,7 @@ func (s *AgentService) RegisterAgent(ctx context.Context, req *AgentRequest) (*A
9292 agent .AgentKey = key
9393 err = s .DBConnection .Create (agent )
9494 if err != nil {
95- catcher .Error ("failed to create agent" , err , nil )
95+ catcher .Error ("failed to create agent" , err , map [ string ] any { "process" : "agent-manager" } )
9696 return nil , status .Error (codes .Internal , fmt .Sprintf ("failed to create agent: %v" , err ))
9797 }
9898
@@ -106,7 +106,7 @@ func (s *AgentService) RegisterAgent(ctx context.Context, req *AgentRequest) (*A
106106 LastPing : time .Now (),
107107 }
108108
109- catcher .Info ("Agent registered correctly" , map [string ]any {"hostname" : agent .Hostname , "id" : agent .ID })
109+ catcher .Info ("Agent registered correctly" , map [string ]any {"hostname" : agent .Hostname , "id" : agent .ID , "process" : "agent-manager" })
110110 return & AuthResponse {
111111 Id : uint32 (agent .ID ),
112112 Key : key ,
@@ -126,7 +126,7 @@ func (s *AgentService) UpdateAgent(ctx context.Context, req *AgentRequest) (*Aut
126126 agent := & models.Agent {}
127127 err = s .DBConnection .GetFirst (agent , "id = ?" , idInt )
128128 if err != nil {
129- catcher .Error ("failed to fetch agent" , err , nil )
129+ catcher .Error ("failed to fetch agent" , err , map [ string ] any { "process" : "agent-manager" } )
130130 return nil , status .Errorf (codes .NotFound , "agent not found" )
131131 }
132132
@@ -157,7 +157,7 @@ func (s *AgentService) UpdateAgent(ctx context.Context, req *AgentRequest) (*Aut
157157
158158 err = s .DBConnection .Upsert (& agent , "id = ?" , nil , idInt )
159159 if err != nil {
160- catcher .Error ("failed to update agent" , err , nil )
160+ catcher .Error ("failed to update agent" , err , map [ string ] any { "process" : "agent-manager" } )
161161 return nil , status .Errorf (codes .Internal , "failed to update agent: %v" , err )
162162 }
163163
@@ -181,18 +181,18 @@ func (s *AgentService) DeleteAgent(ctx context.Context, req *DeleteRequest) (*Au
181181
182182 err = s .DBConnection .Upsert (& models.Agent {}, "id = ?" , map [string ]interface {}{"deleted_by" : req .DeletedBy }, id )
183183 if err != nil {
184- catcher .Error ("unable to update delete_by field in agent" , err , nil )
184+ catcher .Error ("unable to update delete_by field in agent" , err , map [ string ] any { "process" : "agent-manager" } )
185185 }
186186
187187 err = s .DBConnection .Delete (& models.AgentCommand {}, "agent_id = ?" , false , uint (idInt ))
188188 if err != nil {
189- catcher .Error ("unable to delete agent commands" , err , nil )
189+ catcher .Error ("unable to delete agent commands" , err , map [ string ] any { "process" : "agent-manager" } )
190190 return & AuthResponse {}, status .Error (codes .Internal , fmt .Sprintf ("unable to delete agent commands: %v" , err .Error ()))
191191 }
192192
193193 err = s .DBConnection .Delete (& models.Agent {}, "id = ?" , false , id )
194194 if err != nil {
195- catcher .Error ("unable to delete agent" , err , nil )
195+ catcher .Error ("unable to delete agent" , err , map [ string ] any { "process" : "agent-manager" } )
196196 return & AuthResponse {}, status .Error (codes .Internal , fmt .Sprintf ("unable to delete agent: %v" , err .Error ()))
197197 }
198198
@@ -204,7 +204,7 @@ func (s *AgentService) DeleteAgent(ctx context.Context, req *DeleteRequest) (*Au
204204 delete (s .AgentStreamMap , uint (idInt ))
205205 s .AgentStreamMutex .Unlock ()
206206
207- catcher .Info ("Agent deleted" , map [string ]any {"key" : key , "deleted_by" : req .DeletedBy })
207+ catcher .Info ("Agent deleted" , map [string ]any {"key" : key , "deleted_by" : req .DeletedBy , "process" : "agent-manager" })
208208
209209 return & AuthResponse {
210210 Id : uint32 (idInt ),
@@ -219,7 +219,7 @@ func (s *AgentService) ListAgents(ctx context.Context, req *ListRequest) (*ListA
219219 agents := []models.Agent {}
220220 total , err := s .DBConnection .GetByPagination (& agents , page , filter , "" , false )
221221 if err != nil {
222- catcher .Error ("failed to fetch agents" , err , nil )
222+ catcher .Error ("failed to fetch agents" , err , map [ string ] any { "process" : "agent-manager" } )
223223 return nil , status .Errorf (codes .Internal , "failed to fetch agents: %v" , err )
224224 }
225225
@@ -267,7 +267,7 @@ func (s *AgentService) AgentStream(stream AgentService_AgentStreamServer) error
267267
268268 switch msg := in .StreamMessage .(type ) {
269269 case * BidirectionalStream_Result :
270- catcher .Info ("Received command result from agent" , map [string ]any {"agent_id" : msg .Result .AgentId , "result" : msg .Result .Result })
270+ catcher .Info ("Received command result from agent" , map [string ]any {"agent_id" : msg .Result .AgentId , "result" : msg .Result .Result , "process" : "agent-manager" })
271271 cmdID := msg .Result .GetCmdId ()
272272
273273 s .CommandResultChannelM .Lock ()
@@ -279,7 +279,7 @@ func (s *AgentService) AgentStream(stream AgentService_AgentStreamServer) error
279279 ExecutedAt : msg .Result .ExecutedAt ,
280280 }
281281 } else {
282- catcher .Error ("failed to find result channel for CmdID" , nil , map [string ]any {"cmdID" : cmdID })
282+ catcher .Error ("failed to find result channel for CmdID" , nil , map [string ]any {"cmdID" : cmdID , "process" : "agent-manager" })
283283 }
284284 s .CommandResultChannelM .Unlock ()
285285 }
@@ -325,7 +325,7 @@ func (s *AgentService) ProcessCommand(stream PanelService_ProcessCommandServer)
325325 histCommand := createHistoryCommand (cmd , cmdID , uint (streamId ))
326326 err = s .DBConnection .Create (& histCommand )
327327 if err != nil {
328- catcher .Error ("unable to create a new command history" , err , nil )
328+ catcher .Error ("unable to create a new command history" , err , map [ string ] any { "process" : "agent-manager" } )
329329 }
330330
331331 err = agentStream .Send (& BidirectionalStream {
@@ -349,7 +349,7 @@ func (s *AgentService) ProcessCommand(stream PanelService_ProcessCommandServer)
349349 cmd .AgentId , cmdID ,
350350 )
351351 if err != nil {
352- catcher .Error ("failed to update command status" , err , nil )
352+ catcher .Error ("failed to update command status" , err , map [ string ] any { "process" : "agent-manager" } )
353353 }
354354
355355 err = stream .Send (result )
@@ -370,7 +370,7 @@ func (s *AgentService) ListAgentCommands(ctx context.Context, req *ListRequest)
370370 commands := []models.AgentCommand {}
371371 total , err := s .DBConnection .GetByPagination (& commands , page , filter , "" , false )
372372 if err != nil {
373- catcher .Error ("failed to fetch agent commands" , err , nil )
373+ catcher .Error ("failed to fetch agent commands" , err , map [ string ] any { "process" : "agent-manager" } )
374374 return nil , status .Errorf (codes .Internal , "failed to fetch agent commands: %v" , err )
375375 }
376376
0 commit comments