Source code for worldline.acquiring.sdk.log.request_log_message

from .body_obfuscator import BodyObfuscator
from .header_obfuscator import HeaderObfuscator
from .log_message import LogMessage


[docs] class RequestLogMessage(LogMessage): """ A utility class to build request log messages. """ def __init__(self, request_id: str, method: str, uri: str, body_obfuscator: BodyObfuscator = BodyObfuscator.default_body_obfuscator(), header_obfuscator: HeaderObfuscator = HeaderObfuscator.default_header_obfuscator()): super(RequestLogMessage, self).__init__(request_id, body_obfuscator, header_obfuscator) self.method = method self.uri = uri
[docs] def get_message(self) -> str: string = "Outgoing request (requestId='" + str(self.request_id) + "'):\n" + \ " method: " + self.empty_if_none("'" + self.method + "'") + "\n" + \ " uri: " + self.empty_if_none("'" + self.uri + "'") + "\n" + \ " headers: " + self.headers body = self.body if body is None: return string else: return string + "\n content-type: '" + self.empty_if_none(self.content_type) + "'\n" + \ " body: '" + body + "'"