Skip to content

Commit

Permalink
docs: remove python debugging stuff, pulling into a future blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Aug 5, 2023
1 parent fcaaf19 commit 405fc86
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,3 @@
* Can we use cointracker to get external portfolio data?
* Check prices across exchanges?
https://marketplace.visualstudio.com/items?itemName=ms-python.isort

## Document Logger: Response

# https://stackoverflow.com/questions/16337511/log-all-requests-from-the-python-requests-module
logger = logging.getLogger("httplogger")
user.binance_client().session
session.hooks["response"].append(logRoundtrip)
def logRoundtrip(response, *args, **kwargs):
extra = {"req": response.request, "res": response}
logger.debug("HTTP roundtrip", extra=extra)

## Document Logger: Raw Stuff

def debug_requests_on():
"""Switches on logging of the requests module."""
HTTPConnection.debuglevel = 2

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True


def debug_requests_off():
"""Switches off logging of the requests module, might be some side-effects"""
HTTPConnection.debuglevel = 0

root_logger = logging.getLogger()
root_logger.setLevel(logging.WARNING)
root_logger.handlers = []
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.WARNING)
requests_log.propagate = False


@contextlib.contextmanager
def debug_requests():
"""Use with 'with'!"""
debug_requests_on()
yield
debug_requests_off()


0 comments on commit 405fc86

Please sign in to comment.