Skip to content

[19.0][ADD] endpoint_log: log endpoint requests in database - #191

Draft
AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-add-endpoint_log
Draft

AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-add-endpoint_log

Conversation

@AungKoKoLin1997

@AungKoKoLin1997 AungKoKoLin1997 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

This module logs the requests and responses of endpoints (endpoint.endpoint) in the database, using the generic api.log model of api_log (OCA/rest-framework), as fastapi_log does for fastapi.endpoint.

Each endpoint gets a Log Requests switch and a Logs smart button. Each log stores the request URL, method, headers, body and date, the response status, headers and body, the elapsed time and, when the call failed, the stack trace. Logs are written with a separate database connection, so the logs of failed calls are kept even though the call's own transaction is rolled back.

Draft until it is agreed where this module should live (#190), and until OCA/rest-framework#616 (api_log for 19.0) is merged. test-requirements.txt points at that PR in the meantime.

@qrtl QT7417

Assisted-by: Claude Opus 5.5

Endpoints have no record of the calls they receive: the server log holds
only what the code chooses to write, and nothing ties it to the request
and response. This makes webhook and integration issues hard to debug in
production.

This module plugs endpoint.endpoint into api_log, as fastapi_log does for
fastapi.endpoint: a "Log Requests" switch per endpoint, and the request,
response, timing and stack trace of each call stored in api.log.

Logging hooks into ir.http._dispatch rather than the endpoint controller,
because endpoint routes call their controller class by its dotted path,
so a controller override in another module is never reached. Logs are
written through a separate cursor so the logs of failed calls survive the
rollback of their transaction.

api.log is also adapted to plain Odoo routes, where an HTTP error reaches
the logger as a werkzeug exception rather than a response.

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants