Closed Mat-moran closed 2 years ago
Enabling it for the whole collection is enough if you want to track all the calls for it. See the example for shopfloor https://github.com/OCA/wms/blob/13.0/shopfloor_base/controllers/main.py#L10 which is enabled by shopfloor_rest_log https://github.com/OCA/wms/blob/13.0/shopfloor_rest_log/hooks.py#L17.
Now, based on the error I see there it's very likely that the log entry cannot be created because the endpoint is returning something which is not JSON compatible. If that's the case it breaks here https://github.com/OCA/rest-framework/blob/14.0/rest_log/components/service.py#L120. Dropping a pdb there should help you find the issue.
Thanks @simahawk for your quickly answer,
with respect to the res_log I understood that I need to do a small module to be able to see shopinvader logs, the same you did for shopfloor_rest_log
.
with respect to the pdb I will give a try to see what is happening, It is very strange because If I did with pure ReactJs (it launch the request from the browser) or Postman or Curl I can create the customer but If I do from the nextjs api (it launch the request from the server), same header and body as the others it give me the error above. Let see If I can see the headers of the request and check what is happening there...
Thanks again! :smile:
with respect to the res_log I understood that I need to do a small module to be able to see shopinvader logs, the same you did for
shopfloor_rest_log
.
No, you don't need a module (unless you want to add default config for your own service). Just configure the config param properly. What you have to do is to check what you get into the values that are converted to json. Is pretty easy to have a "stupid" value which makes JSON not happy (eg: a date object)
Ohh yes my fault! you are right this is only a post installation hook!
I can not find a suitable value that make it work...
There are 2 values that I can configure in rest_log
module:
rest.log.retention.days
: default value is 30 so I do not have to change thatrest.log.active
: default value is "". I changed it to base.shopinvader.service
that is the name of the main shopinvader service bit it does not work.class BaseShopinvaderService(AbstractComponent):
_inherit = "base.rest.service"
_name = "base.shopinvader.service"
_collection = "shopinvader.backend"
_expose_model = None
I notice that in the shopinvader module controller
folder has been replaced by component
folder so I tried also base.shopinvader.component
as a parameter for res.log.active
, no success.
The controller
folder is only in the module shopinvader_auth_api_key
with a value for the collection of shopinvader.backend
. I tried also with this one in res.log.active
without success.
from odoo.addons.base_rest.controllers import main
class InvaderController(main.RestController):
_root_path = "/shopinvader/"
_collection_name = "shopinvader.backend"
_default_auth = "api_key"
_default_save_session = False
_component_context_provider = "auth_api_key_component_context_provider"
I know I am reaching the shopinvader API because I can see the requests in the logs.
That's wrong, the main key is the collection name, not the service name. Check this https://github.com/OCA/rest-framework/tree/13.0/rest_log#id4
That's wrong, the main key is the collection name, not the service name. Check this https://github.com/OCA/rest-framework/tree/13.0/rest_log#id4
ah, wait, this is v13 and you are on v14 probably which does not have an advanced filtering.... :thinking: :sweat_smile: If that's the case, feel free to fwd port my improvements :wink:
Yeah I am on v14.
I tried as I said before the collection name that is shopinvader.backend
without success.
I will take a look of what you do and I will try to fwd port . Thanks @simahawk for the time!
Dear @simahawk I copy your work and did a PR for v14 -> #201 . I keep the same commit history as you in v13.0.
I can see the logs now, but only the succesfull request. I can not see ERROR requests.
It also happens on v13.0?
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.
Hi I am trying to configure
rest_log
module but I do not catch any log in the log table.When I install the module the value
rest.log.active
was empty. No logs in the table. I tried to put different values for example the collection nameshopinvader.backend
of the service I am trying to expose that is shopinvader API, but this does not work, I tried with the path of the enpoint but also did't work.I can see the logs in the odoo logs but not in the table. I need to see the logs because I am facing problems sending a
POST
request with body and I am getting the next error:INFO shopinvader odoo.addons.base_rest.http: /shopinvader/customer/create: Invalid JSON data: Expecting value: line 1 column 1 (char 0)
Is there any parameter o extra configuration needed that it is not in the docs?
Thanks in advance