Skip to content

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

Open

Description

@AungKoKoLin1997

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions