Commit 9df1a323 authored by Christophe Benz's avatar Christophe Benz
Browse files

Tweak log messages, use JSON

parent f05cc310
"""PDF report rendering utilities."""
import json
from abc import ABC, abstractmethod
import logging
......@@ -32,12 +33,11 @@ class BrowserlessPDFRenderer(PDFRenderer):
"""Browserless IO implementation."""
def __init__(self, api_url: str, api_token: str):
log.info('BrowserlessPDFRenderer(%s,XXX)', api_url)
log.info("BrowserlessPDFRenderer: creating instance with api_url = %r", api_url)
self.api_url = api_url
self.api_token = api_token
def render(self, url: str):
log.info("BrowserlessPDFRenderer.render(%s)", url)
headers = {
"Cache-Control": "no-cache",
"Content-Type": "application/json",
......@@ -51,12 +51,18 @@ class BrowserlessPDFRenderer(PDFRenderer):
"format": "A4",
},
}
log.info("BrowserlessPDFRenderer.render data = %r", data)
log.info(
"BrowserlessPDFRenderer.render: about to send a POST request to "
"browserless with data = %r and headers = %r",
json.dumps(data),
json.dumps(headers),
)
# Request server
log.info("BrowserlessPDFRenderer.render before post")
r = requests.post(self.api_url, headers=headers, params=params, json=data)
log.info("BrowserlessPDFRenderer.render after post")
r.raise_for_status()
log.info("BrowserlessPDFRenderer.render content size = %d", len(r.content))
log.info(
"BrowserlessPDFRenderer.render: received response, content size = %d",
len(r.content),
)
return r.content
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment