diff options
author | Alexandre Flament <alex@al-f.net> | 2021-09-06 21:42:30 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-09-11 10:13:14 +0200 |
commit | 91a6d80e8291852264abdcda83c203dfb5770381 (patch) | |
tree | 6d41010547584f05e8c91bab1751b3137a25fec8 /searx/network/client.py | |
parent | 577998106aed4c3df5cda8f6af77d55dda8ef60c (diff) | |
download | searxng-91a6d80e8291852264abdcda83c203dfb5770381.tar.gz searxng-91a6d80e8291852264abdcda83c203dfb5770381.zip |
[mod] debug mode: log HTTP requests with network name
For example wikipedia requests use the logger name "searx.network.wikipedia"
Log is disable when searx_debug is False
Diffstat (limited to 'searx/network/client.py')
-rw-r--r-- | searx/network/client.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/searx/network/client.py b/searx/network/client.py index 187ae5366..e1abff05a 100644 --- a/searx/network/client.py +++ b/searx/network/client.py @@ -194,7 +194,7 @@ def new_client( # pylint: disable=too-many-arguments enable_http, verify, enable_http2, max_connections, max_keepalive_connections, keepalive_expiry, - proxies, local_address, retries, max_redirects ): + proxies, local_address, retries, max_redirects, hook_log_response ): limit = httpx.Limits( max_connections=max_connections, max_keepalive_connections=max_keepalive_connections, @@ -221,7 +221,17 @@ def new_client( mounts['http://'] = AsyncHTTPTransportNoHttp() transport = get_transport(verify, enable_http2, local_address, None, limit, retries) - return httpx.AsyncClient(transport=transport, mounts=mounts, max_redirects=max_redirects) + + event_hooks = None + if hook_log_response: + event_hooks = {'response': [ hook_log_response ]} + + return httpx.AsyncClient( + transport=transport, + mounts=mounts, + max_redirects=max_redirects, + event_hooks=event_hooks, + ) def get_loop(): @@ -231,7 +241,7 @@ def get_loop(): def init(): # log - for logger_name in ('hpack.hpack', 'hpack.table'): + for logger_name in ('hpack.hpack', 'hpack.table', 'httpx._client'): logging.getLogger(logger_name).setLevel(logging.WARNING) # loop |