Skip to content

Commit a45be9a

Browse files
committed
refactor: log agent state changes on config updates
Add state transition logs in AgentState::update_config and update_partial_config so enabled/disabled changes from config updates are visible with the same format used by other AgentState transitions.
1 parent 7a72b76 commit a45be9a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

agent/src/trident.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ impl AgentState {
281281
return;
282282
}
283283
let mut sg = self.state.lock().unwrap();
284+
let old_state: State = sg.0.into();
284285
sg.0.enabled = config.user_config.global.common.enabled;
286+
let new_state: State = sg.0.into();
287+
if old_state != new_state {
288+
info!("Agent state changed from {old_state:?} to {new_state:?} (enabled: {} melted_down: {})", sg.0.enabled, sg.0.melted_down);
289+
}
285290
sg.1.replace(config);
286291
self.notifier.notify_one();
287292
}
@@ -293,7 +298,12 @@ impl AgentState {
293298
return;
294299
}
295300
let mut sg = self.state.lock().unwrap();
301+
let old_state: State = sg.0.into();
296302
sg.0.enabled = user_config.global.common.enabled;
303+
let new_state: State = sg.0.into();
304+
if old_state != new_state {
305+
info!("Agent state changed from {old_state:?} to {new_state:?} (enabled: {} melted_down: {})", sg.0.enabled, sg.0.melted_down);
306+
}
297307
if let Some(changed_config) = sg.1.as_mut() {
298308
changed_config.user_config = user_config;
299309
} else {

0 commit comments

Comments
 (0)