feat(logging): Integrate log pruning and auto-whitelisting into app lifecycle
This commit is contained in:
@@ -86,8 +86,20 @@ def open_session(label: str | None = None):
|
||||
|
||||
|
||||
def close_session():
|
||||
"""Flush and close all log files. Called on clean exit (optional)."""
|
||||
global _comms_fh, _tool_fh, _api_fh, _cli_fh
|
||||
"""Flush and close all log files. Called on clean exit."""
|
||||
global _comms_fh, _tool_fh, _api_fh, _cli_fh, _session_id, _LOG_DIR
|
||||
|
||||
if _comms_fh is None:
|
||||
return
|
||||
|
||||
# Trigger auto-whitelist update for this session before closing
|
||||
try:
|
||||
from log_registry import LogRegistry
|
||||
registry = LogRegistry(str(_LOG_DIR / "log_registry.toml"))
|
||||
registry.update_auto_whitelist_status(_session_id)
|
||||
except Exception as e:
|
||||
print(f"Warning: Could not update auto-whitelist on close: {e}")
|
||||
|
||||
if _comms_fh:
|
||||
_comms_fh.close()
|
||||
_comms_fh = None
|
||||
@@ -97,7 +109,7 @@ def close_session():
|
||||
if _api_fh:
|
||||
_api_fh.close()
|
||||
_api_fh = None
|
||||
if _cli_fh: # Close the new log file handle
|
||||
if _cli_fh:
|
||||
_cli_fh.close()
|
||||
_cli_fh = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user