Skip to content

Commit

Permalink
WEB-4152 : Add some logs to debug forwarding requests
Browse files Browse the repository at this point in the history
  • Loading branch information
boulch committed Oct 2, 2024
1 parent 4b44bb7 commit d0d1e0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
1.2.72 (unreleased)
-------------------

- WEB-4152 : Add some logs to debug forwarding requests
[boulch]

- WEB-4134 : Add default values to some smartweb settings fields
[boulch]

Expand Down
9 changes: 9 additions & 0 deletions src/imio/smartweb/core/rest/authentic_sources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from imio.smartweb.common.utils import is_log_active
from imio.smartweb.core.config import DIRECTORY_URL
from imio.smartweb.core.config import EVENTS_URL
from imio.smartweb.core.config import NEWS_URL
Expand All @@ -12,9 +13,12 @@
from zope.interface import implementer
from zope.publisher.interfaces import IPublishTraverse

import logging
import os
import requests

logger = logging.getLogger("imio.smartweb.core")


@implementer(IPublishTraverse)
class BaseRequestForwarder(Service):
Expand All @@ -40,6 +44,11 @@ def forward_request(self, url):
method = self.request.method
token = get_wca_token(self.client_id, self.client_secret)
headers = {"Accept": "application/json", "Authorization": token}
if is_log_active():
logger.info("======== Forwarding request to AUTHENTIC SOURCE =========")
logger.info(f"url to forward : {url} ({method})")
logger.info(f"token : {token}")
logger.info(f"headers : {headers}")
params = self.request.form
if method == "GET":
params = self.add_missing_metadatas(params)
Expand Down

0 comments on commit d0d1e0e

Please sign in to comment.