feat: periodically checkpoint server/sud logs to disk
Both loggers previously only wrote their JSON log on their end trigger (shutdown / Stop-or-DONE), losing the whole session/run's data on a hard crash or power loss. Add a log_interval (config.json, default 300s) that rewrites the same file whole every N seconds in between. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TvgC7oy9MxaA4ZQxXqkNdS
This commit is contained in:
+3
-2
@@ -14,8 +14,8 @@ class SudLogTask(ServerLogTask):
|
||||
logs/log_{date_time}_{sud_name}.log. A Pause/resume doesn't start a new
|
||||
file - only a fresh Play (from IDLE/DONE) does."""
|
||||
|
||||
def __init__(self, tc: APid, heater: AHeater, heater_task, sud, interval, path='./logs', config=None, dt=None):
|
||||
ServerLogTask.__init__(self, tc, heater, heater_task, interval, path, config, dt)
|
||||
def __init__(self, tc: APid, heater: AHeater, heater_task, sud, interval, path='./logs', config=None, dt=None, log_interval=None):
|
||||
ServerLogTask.__init__(self, tc, heater, heater_task, interval, path, config, dt, log_interval)
|
||||
self.sud = sud
|
||||
self._active = False
|
||||
|
||||
@@ -31,6 +31,7 @@ class SudLogTask(ServerLogTask):
|
||||
return
|
||||
self._samples = []
|
||||
self._t0 = time.monotonic()
|
||||
self._last_write = self._t0
|
||||
self._run_id = time.strftime("%Y%m%dT%H%M%S", time.localtime())
|
||||
self._active = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user