Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
6875591
1
Parent(s): b52f557
Claude Code: fix blocking mkdir at module import in system_logger.py
Browse filesMove mkdir operation to lazy initialization to prevent blocking
on module import, which was causing RUNNING_APP_STARTING hang.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
openclaw/.openclaw/core/system_logger.py
CHANGED
|
@@ -13,15 +13,17 @@ OPENCLAW_DIR = "/app/.openclaw"
|
|
| 13 |
LOG_DIR = f"{OPENCLAW_DIR}/logs"
|
| 14 |
SYSTEM_LOG = f"{LOG_DIR}/system.log"
|
| 15 |
|
| 16 |
-
# Ensure log directory exists
|
| 17 |
-
Path(LOG_DIR).mkdir(parents=True, exist_ok=True)
|
| 18 |
-
|
| 19 |
# Thread lock for safe concurrent writes
|
| 20 |
_lock = threading.Lock()
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
def _write_log(message: str):
|
| 24 |
"""Internal: write a log entry with timestamp."""
|
|
|
|
| 25 |
with _lock:
|
| 26 |
timestamp = datetime.utcnow().isoformat() + "+00:00"
|
| 27 |
with open(SYSTEM_LOG, "a") as f:
|
|
|
|
| 13 |
LOG_DIR = f"{OPENCLAW_DIR}/logs"
|
| 14 |
SYSTEM_LOG = f"{LOG_DIR}/system.log"
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# Thread lock for safe concurrent writes
|
| 17 |
_lock = threading.Lock()
|
| 18 |
|
| 19 |
+
def _ensure_log_dir():
|
| 20 |
+
"""Ensure log directory exists (lazy, not at import time)."""
|
| 21 |
+
Path(LOG_DIR).mkdir(parents=True, exist_ok=True)
|
| 22 |
+
|
| 23 |
|
| 24 |
def _write_log(message: str):
|
| 25 |
"""Internal: write a log entry with timestamp."""
|
| 26 |
+
_ensure_log_dir()
|
| 27 |
with _lock:
|
| 28 |
timestamp = datetime.utcnow().isoformat() + "+00:00"
|
| 29 |
with open(SYSTEM_LOG, "a") as f:
|