How to use the boxsdk.util.log.sanitize_dictionary function in boxsdk

To help you get started, we’ve selected a few boxsdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github box / box-python-sdk / boxsdk / exception.py View on Github external
def __str__(self):
        return '\n'.join((
            'Message: {self.message}',
            'Status: {self.status}',
            'Code: {self.code}',
            'Request ID: {self.request_id}',
            'Headers: {headers}',
            'URL: {self.url}',
            'Method: {self.method}',
            'Context Info: {self.context_info}',
        )).format(self=self, headers=sanitize_dictionary(self.headers))
github box / box-python-sdk / boxsdk / network / default_network.py View on Github external
if self._did_log:
            return
        self._did_log = True
        content_length = self.headers.get('Content-Length', None)
        content = self.STREAM_CONTENT_NOT_LOGGED
        if can_safely_log_content:
            if content_length is None:
                content_length = text_type(len(self.content))

            # If possible, get the content as a JSON `dict`, that way
            # `pformat(content)` will return pretty-printed JSON.
            try:
                content = self.json()
            except ValueError:
                content = self.content
            content = pformat(sanitize_dictionary(content))
        if content_length is None:
            content_length = '?'
        if self.ok:
            logger_method, response_format = self._logger.info, self.SUCCESSFUL_RESPONSE_FORMAT
        else:
            logger_method, response_format = self._logger.warning, self.ERROR_RESPONSE_FORMAT
        logger_method(
            response_format,
            {
                'method': self.request_response.request.method,
                'url': self.request_response.request.url,
                'status_code': self.status_code,
                'content_length': content_length,
                'headers': pformat(self.headers),
                'content': content,
            },
github box / box-python-sdk / boxsdk / exception.py View on Github external
def __str__(self):
        # pylint:disable=no-member
        if self.network_response:
            headers = sanitize_dictionary(self.network_response.headers)
        # pylint:enable=no-member
        else:
            headers = 'N/A'
        return '\nMessage: {0}\nStatus: {1}\nURL: {2}\nMethod: {3}\nHeaders: {4}'.format(
            self.message,
            self.status,
            self.url,
            self.method,
            headers,
        )
github box / box-python-sdk / boxsdk / network / default_network.py View on Github external
:param method:
            The HTTP verb that should be used to make the request.
        :type method:
            `unicode`
        :param url:
            The URL for the request.
        :type url:
            `unicode`
        :param access_token:
            The OAuth2 access token used to authorize the request.
        :type access_token:
            `unicode`
        """
        self._logger.info(
            self.REQUEST_FORMAT,
            {'method': method, 'url': url, 'request_kwargs': pformat(sanitize_dictionary(kwargs))},
        )