mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
Fix some server implementations not properly logging context
This commit is contained in:
@ -26,8 +26,9 @@ from pr_agent.git_providers.utils import apply_repo_settings
|
|||||||
from pr_agent.log import get_logger
|
from pr_agent.log import get_logger
|
||||||
from fastapi import Request, Depends
|
from fastapi import Request, Depends
|
||||||
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||||
from pr_agent.log import get_logger
|
from pr_agent.log import LoggingFormat, get_logger, setup_logger
|
||||||
|
|
||||||
|
setup_logger(fmt=LoggingFormat.JSON, level="DEBUG")
|
||||||
security = HTTPBasic()
|
security = HTTPBasic()
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
available_commands_rgx = re.compile(r"^\/(" + "|".join(command2class.keys()) + r")\s*")
|
available_commands_rgx = re.compile(r"^\/(" + "|".join(command2class.keys()) + r")\s*")
|
||||||
@ -40,8 +41,12 @@ def handle_request(
|
|||||||
):
|
):
|
||||||
log_context["action"] = body
|
log_context["action"] = body
|
||||||
log_context["api_url"] = url
|
log_context["api_url"] = url
|
||||||
with get_logger().contextualize(**log_context):
|
|
||||||
background_tasks.add_task(PRAgent().handle_request, url, body)
|
async def inner():
|
||||||
|
with get_logger().contextualize(**log_context):
|
||||||
|
await PRAgent().handle_request(url, body)
|
||||||
|
|
||||||
|
background_tasks.add_task(inner)
|
||||||
|
|
||||||
|
|
||||||
# currently only basic auth is supported with azure webhooks
|
# currently only basic auth is supported with azure webhooks
|
||||||
|
@ -13,9 +13,10 @@ from starlette_context.middleware import RawContextMiddleware
|
|||||||
|
|
||||||
from pr_agent.agent.pr_agent import PRAgent
|
from pr_agent.agent.pr_agent import PRAgent
|
||||||
from pr_agent.config_loader import get_settings
|
from pr_agent.config_loader import get_settings
|
||||||
from pr_agent.log import get_logger
|
from pr_agent.log import LoggingFormat, get_logger, setup_logger
|
||||||
from pr_agent.servers.utils import verify_signature
|
from pr_agent.servers.utils import verify_signature
|
||||||
|
|
||||||
|
setup_logger(fmt=LoggingFormat.JSON, level="DEBUG")
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@ -24,8 +25,12 @@ def handle_request(
|
|||||||
):
|
):
|
||||||
log_context["action"] = body
|
log_context["action"] = body
|
||||||
log_context["api_url"] = url
|
log_context["api_url"] = url
|
||||||
with get_logger().contextualize(**log_context):
|
|
||||||
background_tasks.add_task(PRAgent().handle_request, url, body)
|
async def inner():
|
||||||
|
with get_logger().contextualize(**log_context):
|
||||||
|
await PRAgent().handle_request(url, body)
|
||||||
|
|
||||||
|
background_tasks.add_task(inner)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/")
|
@router.post("/")
|
||||||
|
@ -27,8 +27,12 @@ def handle_request(background_tasks: BackgroundTasks, url: str, body: str, log_c
|
|||||||
log_context["action"] = body
|
log_context["action"] = body
|
||||||
log_context["event"] = "pull_request" if body == "/review" else "comment"
|
log_context["event"] = "pull_request" if body == "/review" else "comment"
|
||||||
log_context["api_url"] = url
|
log_context["api_url"] = url
|
||||||
with get_logger().contextualize(**log_context):
|
|
||||||
background_tasks.add_task(PRAgent().handle_request, url, body)
|
async def inner():
|
||||||
|
with get_logger().contextualize(**log_context):
|
||||||
|
await PRAgent().handle_request(url, body)
|
||||||
|
|
||||||
|
background_tasks.add_task(inner)
|
||||||
|
|
||||||
|
|
||||||
async def _perform_commands_gitlab(commands_conf: str, agent: PRAgent, api_url: str, log_context: dict):
|
async def _perform_commands_gitlab(commands_conf: str, agent: PRAgent, api_url: str, log_context: dict):
|
||||||
|
Reference in New Issue
Block a user