SynapseFI / SynapseFI-Python

SynapseFI Python API Wrapper
11 stars 13 forks source link

Creating a Client with `logging=True` sets the logging level for requests globally. #12

Open daronstinnett opened 8 years ago

daronstinnett commented 8 years ago

I noticed this because our tests created a client with logging=True, which caused subsequent tests in other applications to log requests to the console. Removing the logging=True kwarg solved the issue.

stevula commented 7 years ago

Thanks. We'll look into it.

https://github.com/synapsepay/SynapsePayRest-Python/blob/master/synapse_pay_rest/http_client.py#L83-L97

    def log_information(self, should_log):
        """Log requests to stdout."""
        if should_log:
            try:
                import http.client as http_client
            except ImportError:
                # Python 2
                import httplib as http_client
            http_client.HTTPConnection.debuglevel = 1

            logging.basicConfig()
            logging.getLogger().setLevel(logging.DEBUG)
            requests_log = logging.getLogger("requests.packages.urllib3")
            requests_log.setLevel(logging.DEBUG)
            requests_log.propagate = True
stevula commented 7 years ago

@sankaet any ideas on how to fix this?