feat: attended PR comments

This commit is contained in:
2026-02-24 22:14:29 +00:00
parent a3ba340224
commit b95bb72b24
4 changed files with 16 additions and 14 deletions

View File

@@ -9,26 +9,24 @@ from typing import Optional, Dict, Literal
import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler
from .config import Settings
from .config import cfg
def _setup_logger() -> logging.Logger:
"""Create or return the singleton evaluation logger."""
log_name = "va_agent-evaluation-logs"
logger = logging.getLogger(log_name)
cfg = Settings.model_validate({})
logger = logging.getLogger(cfg.log_name)
if any(isinstance(h, CloudLoggingHandler) for h in logger.handlers):
return logger
try:
client = google.cloud.logging.Client(project=cfg.project_id)
handler = CloudLoggingHandler(client, name=log_name) # async transport
handler = CloudLoggingHandler(client, name=cfg.log_name) # async transport
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.setLevel(getattr(logging, cfg.log_level.upper()))
except Exception as e:
# Fallback to console if Cloud Logging is unavailable (local dev)
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(log_name)
logging.basicConfig(level=getattr(logging, cfg.log_level.upper()))
logger = logging.getLogger(cfg.log_name)
logger.warning("Cloud Logging setup failed; using console. Error: %s", e)
return logger
@@ -43,7 +41,7 @@ def log_structured_entry(message: str, severity: Literal["INFO", "WARNING", "ERR
Args:
message: Short label for the row (e.g., "Final agent turn").
severity: "INFO" | "WARNING" | "ERROR" etc.
severity: "INFO" | "WARNING" | "ERROR"
custom_log: A dict with your structured payload.
"""
level = getattr(logging, severity.upper(), logging.INFO)