Skip to content

Commit

Permalink
Merge pull request #987 from sphinx-contrib/add-method-name-in-header…
Browse files Browse the repository at this point in the history
…-debug-logs

rest: log method name in header logs
  • Loading branch information
jdknight authored Jun 22, 2024
2 parents cdf2cb5 + 92124df commit d58ebdf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sphinxcontrib/confluencebuilder/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from sphinxcontrib.confluencebuilder.std.confluence import NOCHECK
from sphinxcontrib.confluencebuilder.std.confluence import RSP_HEADER_RETRY_AFTER
from requests.adapters import HTTPAdapter
import inspect
import json
import math
import random
Expand Down Expand Up @@ -406,8 +407,14 @@ def _process_request(self, method, path, *args, **kwargs):

# debug logging
if dump:
# attempt to track the origin of the request
frame = inspect.currentframe().f_back.f_back
while frame and frame.f_code.co_name.startswith('_wrapper'):
frame = frame.f_back
origin = frame.f_code.co_name if frame else 'unknown'

print('') # leading newline, if debugging into active line
print('(debug) Request]')
print(f'(debug) Request: {origin}]')
print(f'{req.method} {req.url}')
print('\n'.join(f'{k}: {v}' for k, v in req.headers.items()))
print('', flush=True)
Expand Down

0 comments on commit d58ebdf

Please sign in to comment.