Skip to content

Commit 869afc3

Browse files
committed
Add print_content arg to vk_api.utils.enable_debug_mode
1 parent 888b315 commit 869afc3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

vk_api/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ def set_cookies_from_list(cookie_jar, l):
9494
cookie_jar.set_cookie(cookie_from_dict(cookie))
9595

9696

97-
def enable_debug_mode(vk_session):
97+
def enable_debug_mode(vk_session, print_content=False):
9898
""" Включает режим отладки:
9999
- Вывод сообщений лога
100100
- Вывод http запросов
101101
102102
:param vk_session: объект VkApi
103+
:param print_content: печатать ответ http запросов
103104
"""
104105

105106
import logging
@@ -117,14 +118,18 @@ def send(self, request, **kwargs):
117118
total = end - start
118119

119120
print(
120-
'{:0.2f} {} {} {}'.format(
121+
'{:0.2f} {} {} {} {}'.format(
121122
total,
122123
request.method,
123124
request.url,
125+
response.status_code,
124126
response.history
125127
)
126128
)
127129

130+
if print_content:
131+
print(response.text)
132+
128133
return response
129134

130135
vk_session.http.mount('http://', DebugHTTPAdapter())

0 commit comments

Comments
 (0)