Log proper headers in trace logs
This commit is contained in:
@@ -61,7 +61,9 @@ class Connection(object):
|
||||
path = path.replace('?', '?pretty&', 1) if '?' in path else path + '?pretty'
|
||||
if self.url_prefix:
|
||||
path = path.replace(self.url_prefix, '', 1)
|
||||
tracer.info("curl -X%s 'http://localhost:9200%s' -d '%s'", method, path, self._pretty_json(body) if body else '')
|
||||
tracer.info("curl %s-X%s 'http://localhost:9200%s' -d '%s'",
|
||||
"-H 'Content-Type: application/json' " if body else '',
|
||||
method, path, self._pretty_json(body) if body else '')
|
||||
|
||||
if tracer.isEnabledFor(logging.DEBUG):
|
||||
tracer.debug('#[%s] (%.3fs)\n#%s', status_code, duration, self._pretty_json(response).replace('\n', '\n#') if response else '')
|
||||
|
||||
@@ -164,7 +164,7 @@ class TestRequestsConnection(TestCase):
|
||||
# trace request
|
||||
self.assertEquals(1, tracer.info.call_count)
|
||||
self.assertEquals(
|
||||
"""curl -XGET 'http://localhost:9200/?pretty¶m=42' -d '{\n "question": "what\\u0027s that?"\n}'""",
|
||||
"""curl -H 'Content-Type: application/json' -XGET 'http://localhost:9200/?pretty¶m=42' -d '{\n "question": "what\\u0027s that?"\n}'""",
|
||||
tracer.info.call_args[0][0] % tracer.info.call_args[0][1:]
|
||||
)
|
||||
# trace response
|
||||
@@ -234,6 +234,6 @@ class TestRequestsConnection(TestCase):
|
||||
# trace request
|
||||
self.assertEquals(1, tracer.info.call_count)
|
||||
self.assertEquals(
|
||||
"curl -XGET 'http://localhost:9200/_search?pretty' -d '{\n \"answer\": 42\n}'",
|
||||
"curl -H 'Content-Type: application/json' -XGET 'http://localhost:9200/_search?pretty' -d '{\n \"answer\": 42\n}'",
|
||||
tracer.info.call_args[0][0] % tracer.info.call_args[0][1:]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user