Skip to content
Snippets Groups Projects
Commit edbd9c77 authored by damien.habets's avatar damien.habets
Browse files

Improve logging

Request contents only logged at debug level.
parent 2fdfb808
No related branches found
No related tags found
2 merge requests!19forward port of 11.0 features,!14Topic/13.0/task 418
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
Move constant converter to converter module. Move constant converter to converter module.
Fix a docstring (not an override). Fix a docstring (not an override).
Credit OCA for report code.
Improve logging - request contents only logged at debug level.
13.0.2.0.1 13.0.2.0.1
========== ==========
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"name": "Redner", "name": "Redner",
"summary": """ "summary": """
Allows to generate transactional emails and documents in PDF or HTML format""", Allows to generate transactional emails and documents in PDF or HTML format""",
"version": "13.0.3.0.1", "version": "13.0.3.0.2",
"category": "Technical", "category": "Technical",
"author": "XCG Consulting", "author": "XCG Consulting",
"website": "http://odoo.consulting/", "website": "http://odoo.consulting/",
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
return self.call_impl(path, http_verb=http_verb, **params) return self.call_impl(path, http_verb=http_verb, **params)
except Exception as error: except Exception as error:
if retry_counter == MAX_REDNERD_TRIES - 1: if retry_counter == MAX_REDNERD_TRIES - 1:
logger.error("Redner error: %s", str(error))
raise error raise error
def call_impl(self, path, http_verb="post", **params): def call_impl(self, path, http_verb="post", **params):
...@@ -51,6 +52,8 @@ ...@@ -51,6 +52,8 @@
path(str): URL path to query, eg. '/template/' path(str): URL path to query, eg. '/template/'
http_verb(str): http verb to use, default: 'post' http_verb(str): http verb to use, default: 'post'
params(dict): json payload params(dict): json payload
This method can raise anything; callers are expected to catch.
""" """
if not self.server_url: if not self.server_url:
...@@ -59,6 +62,6 @@ ...@@ -59,6 +62,6 @@
"Please add it in odoo.conf or in ir.config_parameter" "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() _http_verb = http_verb.upper()
...@@ -63,6 +66,7 @@ ...@@ -63,6 +66,7 @@
_http_verb = http_verb.upper() _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() start = time.time()
r = getattr(self.session, http_verb, "post")( r = getattr(self.session, http_verb, "post")(
...@@ -66,8 +70,8 @@ ...@@ -66,8 +70,8 @@
start = time.time() start = time.time()
r = getattr(self.session, http_verb, "post")( 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 complete_time = time.time() - start
logger.info( logger.info(
...@@ -70,7 +74,8 @@ ...@@ -70,7 +74,8 @@
) )
complete_time = time.time() - start complete_time = time.time() - start
logger.info( logger.info(
"Received %s in %.2fms: %s" "Redner: Received %s in %.2fms.",
% (r.status_code, complete_time * 1000, r.text) r.status_code,
complete_time * 1000,
) )
...@@ -76,4 +81,5 @@ ...@@ -76,4 +81,5 @@
) )
logger.debug("Redner: Received %s", r.text)
try: try:
response = r.json() 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