- Update default models in config to use `claude-opus-4.6`. - Introduce logging configuration to write logs to a file. - Add correlation ID to error responses for better traceability. - Implement diagnostics for summarizing message requests. - Normalize legacy system messages in the API. - Enhance tests to cover new logging and error handling features. - Update README and documentation to reflect changes in model defaults and logging behavior.
27 lines
795 B
Python
27 lines
795 B
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
|
|
LOG_DIR = Path("logs")
|
|
LOG_FILE = LOG_DIR / "nexus-claude-api.log"
|
|
LOG_FORMAT = "%(asctime)s %(levelname)s %(name)s: %(message)s"
|
|
|
|
|
|
def configure_logging(*, verbose: bool = False, log_file: Path = LOG_FILE) -> Path:
|
|
log_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
formatter = logging.Formatter(LOG_FORMAT)
|
|
file_handler = logging.FileHandler(log_file, encoding="utf-8")
|
|
file_handler.setLevel(logging.DEBUG)
|
|
file_handler.setFormatter(formatter)
|
|
|
|
app_logger = logging.getLogger("nexus_claude_api")
|
|
app_logger.handlers.clear()
|
|
app_logger.setLevel(logging.DEBUG if verbose else logging.INFO)
|
|
app_logger.addHandler(file_handler)
|
|
app_logger.propagate = False
|
|
|
|
return log_file
|