mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Tweak logging
This commit is contained in:
parent
538af64955
commit
691ad500c6
4 changed files with 11 additions and 2 deletions
|
@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
|
|||
from typing import Any
|
||||
|
||||
import httpx
|
||||
from loguru import logger
|
||||
from markdown import markdown
|
||||
|
||||
from app import config
|
||||
|
@ -135,6 +136,7 @@ async def fetch(
|
|||
params: dict[str, Any] | None = None,
|
||||
disable_httpsig: bool = False,
|
||||
) -> RawObject:
|
||||
logger.info(f"Fetching {url} ({params=})")
|
||||
check_url(url)
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
@ -342,6 +344,7 @@ def remove_context(raw_object: RawObject) -> RawObject:
|
|||
|
||||
|
||||
async def post(url: str, payload: dict[str, Any]) -> httpx.Response:
|
||||
logger.info(f"Posting {url} ({payload=})")
|
||||
check_url(url)
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
|
|
@ -187,7 +187,7 @@ async def httpsig_checker(
|
|||
server=server,
|
||||
)
|
||||
|
||||
logger.debug(f"hsig={hsig}")
|
||||
# logger.debug(f"hsig={hsig}")
|
||||
signed_string, signature_date = _build_signed_string(
|
||||
hsig["headers"],
|
||||
request.method,
|
||||
|
|
|
@ -3,6 +3,7 @@ import traceback
|
|||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
import httpx
|
||||
from loguru import logger
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy import select
|
||||
|
@ -116,6 +117,11 @@ async def process_next_incoming_activity(
|
|||
next_activity.ap_object,
|
||||
next_activity.sent_by_ap_actor_id,
|
||||
)
|
||||
except httpx.TimeoutException as exc:
|
||||
url = exc._request.url if exc._request else None
|
||||
logger.error(f"HTTP timeout when fetching {url}")
|
||||
next_activity.error = traceback.format_exc()
|
||||
_set_next_try(next_activity)
|
||||
except Exception:
|
||||
logger.exception("Failed")
|
||||
next_activity.error = traceback.format_exc()
|
||||
|
|
|
@ -760,7 +760,7 @@ async def inbox(
|
|||
db_session: AsyncSession = Depends(get_db_session),
|
||||
httpsig_info: httpsig.HTTPSigInfo = Depends(httpsig.enforce_httpsig),
|
||||
) -> Response:
|
||||
logger.info(f"headers={request.headers}")
|
||||
# logger.info(f"headers={request.headers}")
|
||||
payload = await request.json()
|
||||
logger.info(f"{payload=}")
|
||||
await new_ap_incoming_activity(db_session, httpsig_info, payload)
|
||||
|
|
Loading…
Reference in a new issue