Skip to content
Snippets Groups Projects
Commit 556b37a79d44 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Improve logging

Request contents only logged at debug level.

Fixes #1.
parent 3b3e77aff06f
No related branches found
Tags 11.0.2.8.0
1 merge request!11Topic/11.0/zouzou
......@@ -2,6 +2,11 @@
NEWS
====
11.0.2.4.1
==========
* Improve logging - request contents only logged at debug level.
11.0.2.4.0
==========
......
......@@ -21,7 +21,7 @@
"name": "Redner",
"summary": """
Allows to generate transactional emails and documents in PDF or HTML format""",
"version": "11.0.2.4.0",
"version": "11.0.2.4.1",
"author": "XCG Consulting",
"category": "Technical",
"description": """
......
......@@ -41,6 +41,7 @@
return self.call_impl(path, http_verb=http_verb, **params)
except Exception as error:
if retry_counter == MAX_REDNERD_TRIES - 1:
logger.error("Redner error: %s", str(error))
raise error
def call_impl(self, path, http_verb="post", **params):
......@@ -51,6 +52,8 @@
path(str): URL path to query, eg. '/template/'
http_verb(str): http verb to use, default: 'post'
params(dict): json payload
This method can raise anything; callers are expected to catch.
"""
if not self.server_url:
......@@ -59,6 +62,6 @@
"Please add it in odoo.conf or in ir.config_parameter"
)
endpoint = urljoin(self.server_url, path)
url = urljoin(self.server_url, path)
_http_verb = http_verb.upper()
......@@ -63,6 +66,7 @@
_http_verb = http_verb.upper()
logger.info("%s to %s: %s" % (_http_verb, endpoint, params))
logger.info("Redner: Calling %s...", _http_verb)
logger.debug("Redner: Sending to %s > %s", url, params)
start = time.time()
r = getattr(self.session, http_verb, "post")(
......@@ -66,8 +70,8 @@
start = time.time()
r = getattr(self.session, http_verb, "post")(
endpoint, json=params, headers={"Rednerd-API-Key": self.api_key}
url, json=params, headers={"Rednerd-API-Key": self.api_key}
)
complete_time = time.time() - start
logger.info(
......@@ -70,7 +74,8 @@
)
complete_time = time.time() - start
logger.info(
"Received %s in %.2fms: %s"
% (r.status_code, complete_time * 1000, r.text)
"Redner: Received %s in %.2fms.",
r.status_code,
complete_time * 1000,
)
......@@ -76,4 +81,5 @@
)
logger.debug("Redner: Received %s", r.text)
try:
response = r.json()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment