Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

feat(logging): 仅当 config 目录下存在 logging.yaml 时才走配置文件日志流程

alan_chenge68080c8d1fe
diff --git a/.gitignore b/.gitignore
index 6b9a91aa8c..90e9d90454 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,4 +74,7 @@ jiuwenclaw/workspace/.whatsapp-auth/
jiuwenclaw/resources/agent/workspace/
jiuwenclaw/resources/tui/bin/
packages/jiuwenclaw-tui/jiuwenclaw_tui/resources/tui/bin/
-packages/jiuwenclaw-tui/jiuwenclaw_tui/resources/tui-bin/
\ No newline at end of file
+packages/jiuwenclaw-tui/jiuwenclaw_tui/resources/tui-bin/
+
+.crossnote/
+.trae/
\ No newline at end of file
diff --git a/jiuwenclaw/app_agentserver.py b/jiuwenclaw/app_agentserver.py
index 2c75a89e71..5244542ae0 100644
--- a/jiuwenclaw/app_agentserver.py
+++ b/jiuwenclaw/app_agentserver.py
@@ -29,6 +29,7 @@ parse_dotenv_early("jiuwenclaw-agentserver")
# --- Now safe to import jiuwenclaw modules ---
from jiuwenclaw.utils import (
get_env_file,
+ get_root_dir,
get_user_workspace_dir,
logger,
prepare_workspace,
@@ -45,8 +46,13 @@ _old_workspace = _workspace_dir / "agent" / "workspace"
if not _config_file.exists() or (_old_workspace.exists() and not _new_workspace.exists()):
prepare_workspace(overwrite=False)
-for _lg in LogManager.get_all_loggers().values():
- _lg.set_level(logging.CRITICAL)
+_logging_yaml = get_root_dir() / "config" / "logging.yaml"
+if _logging_yaml.exists():
+ from openjiuwen.core.common.logging.log_config import configure_log
+ configure_log(str(_logging_yaml))
+else:
+ for _lg in LogManager.get_all_loggers().values():
+ _lg.set_level(logging.CRITICAL)
# Load env from user workspace config/.env
load_dotenv(dotenv_path=get_env_file(), override=True)
diff --git a/jiuwenclaw/app_gateway.py b/jiuwenclaw/app_gateway.py
index 5c48d67a7f..8a4c2a32b7 100644
--- a/jiuwenclaw/app_gateway.py
+++ b/jiuwenclaw/app_gateway.py
@@ -38,11 +38,12 @@ import jiuwenclaw.channel.acp_channel as acp_channel_module
from jiuwenclaw.channel.acp_channel import AcpGatewayBridge
from jiuwenclaw.gateway.route_binding import GatewayRouteBinding
from jiuwenclaw.utils import (
+ get_cron_jobs_path,
get_env_file,
+ get_root_dir,
get_user_workspace_dir,
prepare_workspace,
reset_free_search_runtime_flags,
- get_cron_jobs_path
)
@@ -56,9 +57,14 @@ _old_workspace = _workspace_dir / "agent" / "workspace"
if not _config_file.exists() or (_old_workspace.exists() and not _new_workspace.exists()):
prepare_workspace(overwrite=False)
-# Reduce openjiuwen internal logs (keep Gateway logs)
-for _lg in LogManager.get_all_loggers().values():
- _lg.set_level(logging.CRITICAL)
+_logging_yaml = get_root_dir() / "config" / "logging.yaml"
+if _logging_yaml.exists():
+ from openjiuwen.core.common.logging.log_config import configure_log
+ configure_log(str(_logging_yaml))
+else:
+ # Reduce openjiuwen internal logs (keep Gateway logs)
+ for _lg in LogManager.get_all_loggers().values():
+ _lg.set_level(logging.CRITICAL)
load_dotenv(dotenv_path=get_env_file(), override=True)
reset_free_search_runtime_flags()
diff --git a/pyproject.toml b/pyproject.toml
index a95b5963da..faf968e986 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -44,7 +44,7 @@ dependencies = [
desktop = ["pywebview>=5.4"]
dev = ["pyinstaller>=6.0.0", "pywebview>=5.4"]
tui = ["jiuwenclaw-tui==0.1.11"]
-distribute = ["openjiuwen[postgres,zmq] @ git+https://gitcode.com/openJiuwen/agent-core.git@develop"]
+distribute = ["openjiuwen[postgres,zmq]"]
shell-ast = [
"tree-sitter>=0.25.0,<0.26.0",
"tree-sitter-bash>=0.25.0,<0.26.0",
diff --git a/uv.lock b/uv.lock
index 099fe39280..8e5327c156 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1594,7 +1594,7 @@ requires-dist = [
{ name = "loguru", specifier = ">=0.7.3" },
{ name = "mutagen", specifier = ">=1.47.0" },
{ name = "openjiuwen", git = "https://gitcode.com/openJiuwen/agent-core.git?rev=develop" },
- { name = "openjiuwen", extras = ["postgres", "zmq"], marker = "extra == 'distribute'", git = "https://gitcode.com/openJiuwen/agent-core.git?rev=develop" },
+ { name = "openjiuwen", extras = ["postgres", "zmq"], marker = "extra == 'distribute'" },
{ name = "opentelemetry-api", specifier = ">=1.25.0" },
{ name = "opentelemetry-exporter-otlp-proto-grpc", specifier = ">=1.25.0" },
{ name = "opentelemetry-exporter-otlp-proto-http", specifier = ">=1.25.0" },