[19.0] endpoint_log: log endpoint calls in database with api_log

未关闭
#190 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

Start with the open question of which repository should host the module, since that decides the dependency direction. Then read fastapi_log in OCA/rest-framework as the model for the bridge, and look at how ir.http._dispatch receives the functools.partial registered by endpoint_route_handler in web-api. Done means a maintainer has chosen the location and a bridge module logs endpoint calls to api.log, with the migration tracked in OCA/rest-framework#616.

由索引模型根据 Issue 内容生成。

描述

Endpoints currently leave no database record of the calls they receive. The log() helper available to code snippets writes manual messages to ir.logging, and nothing records the request and response themselves.

OCA/rest-framework already provides a generic model for this. api_log stores the URL, method, sanitised headers, body, status, timing and stack trace in api.log, and its api.log_collection.mixin adds a log switch and a Logs button to any model. fastapi_log is the bridge for fastapi.endpoint. The 19.0 migration is OCA/rest-framework#616.

I'd like to contribute an endpoint_log bridge for endpoint.endpoint, and I have a working version for 19.0:

  • endpoint.endpoint inherits api.log_collection.mixin.
  • Logging hooks into ir.http._dispatch, which receives the functools.partial that endpoint_route_handler registers for each route. The endpoint record is resolved from it. The controller is not overridden, because routes call it by its dotted path.
  • Logs are written through a separate cursor, as in fastapi_log, so the logs of failed calls are kept.
  • api_log depends only on web, so the dependency stays light.

Question for maintainers: where should this module live?

  1. In web-api, depending on OCA/rest-framework for api_log.
  2. In rest-framework, next to fastapi_log, depending on web-api for endpoint.

I'd lean towards web-api, since the module is about endpoints, but I'm happy to go either way.

@qrtl QT7417

Assisted-by: Claude Opus 5.5

主要语言
Python
星标
49
派生
124
平均合并
4 天 13 小时
30 天内合并 PR
11

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OCA/web-api 的其他 Issue

查看 OCA/web-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。