File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616"""Common client utilities"""
1717
18+ import logging
1819import os
1920import six
2021import sys
@@ -215,3 +216,16 @@ def wait_for_status(status_f,
215216 callback (progress )
216217 time .sleep (sleep_time )
217218 return retval
219+
220+
221+ def get_effective_log_level ():
222+ """Returns the lowest logging level considered by logging handlers
223+
224+ Retrieve an return the smallest log level set among the root
225+ logger's handlers (in case of multiple handlers).
226+ """
227+ root_log = logging .getLogger ()
228+ min_log_lvl = logging .CRITICAL
229+ for handler in root_log .handlers :
230+ min_log_lvl = min (min_log_lvl , handler .level )
231+ return min_log_lvl
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ def make_client(instance):
3535 instance ._api_version [API_NAME ],
3636 API_VERSIONS )
3737 LOG .debug ('instantiating compute client: %s' % compute_client )
38+
39+ # Set client http_log_debug to True if verbosity level is high enough
40+ http_log_debug = utils .get_effective_log_level () <= logging .DEBUG
41+
3842 client = compute_client (
3943 username = instance ._username ,
4044 api_key = instance ._password ,
@@ -49,7 +53,8 @@ def make_client(instance):
4953 extensions = [],
5054 service_type = API_NAME ,
5155 # FIXME(dhellmann): what is service_name?
52- service_name = '' )
56+ service_name = '' ,
57+ http_log_debug = http_log_debug )
5358
5459 # Populate the Nova client to skip another auth query to Identity
5560 if instance ._url :
Original file line number Diff line number Diff line change @@ -37,13 +37,18 @@ def make_client(instance):
3737 )
3838
3939 LOG .debug ('instantiating volume client' )
40+
41+ # Set client http_log_debug to True if verbosity level is high enough
42+ http_log_debug = utils .get_effective_log_level () <= logging .DEBUG
43+
4044 client = volume_client (
4145 username = instance ._username ,
4246 api_key = instance ._password ,
4347 project_id = instance ._project_name ,
4448 auth_url = instance ._auth_url ,
4549 cacert = instance ._cacert ,
4650 insecure = instance ._insecure ,
51+ http_log_debug = http_log_debug
4752 )
4853
4954 return client
You can’t perform that action at this time.
0 commit comments