Repository navigation
[19.0][ADD] endpoint_log: log endpoint requests in database - #191
Draft
AungKoKoLin1997 wants to merge 1 commit into
Draft
AungKoKoLin1997 wants to merge 1 commit into
AungKoKoLin1997 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This module logs the requests and responses of endpoints (
endpoint.endpoint) in the database, using the genericapi.logmodel ofapi_log(OCA/rest-framework), asfastapi_logdoes forfastapi.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_logfor 19.0) is merged.test-requirements.txtpoints at that PR in the meantime.@qrtl QT7417
Assisted-by: Claude Opus 5.5