ENGINE: Migrated Logs to Runtime Folders

This commit is contained in:
2025-10-29 15:19:29 -06:00
parent 98737fb737
commit 8fa7bd4fb0
11 changed files with 36 additions and 33 deletions

View File

@@ -242,7 +242,7 @@ class Role:
self._ansible_ready = False
self._ansible_bootstrap_lock = None
try:
base = os.path.join(_project_root(), 'Logs', 'Agent')
base = os.path.join(_project_root(), 'Agent', 'Logs')
os.makedirs(base, exist_ok=True)
self._ansible_log(f"[init] PlaybookExec role init agent_id={ctx.agent_id}")
except Exception:
@@ -580,7 +580,7 @@ class Role:
def _log_local(self, msg: str, error: bool = False):
try:
base = os.path.join(_project_root(), 'Logs', 'Agent')
base = os.path.join(_project_root(), 'Agent', 'Logs')
os.makedirs(base, exist_ok=True)
fn = 'agent.error.log' if error else 'agent.log'
ts = time.strftime('%Y-%m-%d %H:%M:%S')
@@ -600,7 +600,7 @@ class Role:
def _ansible_log(self, msg: str, error: bool = False, run_id: str = None):
try:
d = os.path.join(_project_root(), 'Logs', 'Agent')
d = os.path.join(_project_root(), 'Agent', 'Logs')
ts = time.strftime('%Y-%m-%d %H:%M:%S')
path = os.path.join(d, 'ansible.log')
try:
@@ -716,7 +716,7 @@ class Role:
if os.name != 'nt':
return
mod = self._ps_module_path()
log_dir = os.path.join(_project_root(), 'Logs', 'Agent')
log_dir = os.path.join(_project_root(), 'Agent', 'Logs')
try:
os.makedirs(log_dir, exist_ok=True)
except Exception:

View File

@@ -219,7 +219,7 @@ def _run_powershell_via_system_task(content: str, env_map: Dict[str, str], timeo
with os.fdopen(script_fd, 'w', encoding='utf-8', newline='\n') as f:
f.write(final_content)
try:
log_dir = os.path.join(_project_root(), 'Logs', 'Agent')
log_dir = os.path.join(_project_root(), 'Agent', 'Logs')
os.makedirs(log_dir, exist_ok=True)
with open(os.path.join(log_dir, 'system_last.ps1'), 'w', encoding='utf-8', newline='\n') as df:
df.write(content or '')