Enhance user configuration management and logging

- Introduced user configuration command to set API key.
- Updated README and documentation for user config and logging paths.
- Refactored logging to support user-specific log files.
- Added tests for user configuration and logging behavior.
This commit is contained in:
2026-06-27 10:21:00 +08:00
parent 0e98ce57d4
commit 4685a0165d
10 changed files with 434 additions and 25 deletions

View File

@@ -1,8 +1,9 @@
from __future__ import annotations
import logging
from pathlib import Path
from nexus_claude_api.logging_config import configure_logging
from nexus_claude_api.logging_config import configure_logging, resolve_log_file
def test_configure_logging_writes_app_logs_to_file_without_console(
@@ -55,3 +56,17 @@ def test_configure_logging_verbose_writes_debug_app_logs_to_file(
app_logger.handlers.extend(original_handlers)
app_logger.setLevel(original_level)
app_logger.propagate = original_propagate
def test_resolve_log_file_uses_user_config_dir_by_default(
tmp_path,
monkeypatch,
) -> None:
user_config_dir = tmp_path / ".config" / "nexus-claude-api"
monkeypatch.setattr("nexus_claude_api.config.USER_CONFIG_DIR", user_config_dir)
assert resolve_log_file() == user_config_dir / "logs" / "nexus-claude-api.log"
def test_resolve_log_file_uses_local_logs_in_dev_mode() -> None:
assert resolve_log_file(dev=True) == Path("logs") / "nexus-claude-api.log"