Skip to content

Commit 049dbe8

Browse files
authored
Merge pull request #59 from Microsoft/users/tedchamb/regen
Add more info when debug logging is enabled.
2 parents d283d07 + 69b16fe commit 049dbe8

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

vsts/vsts/_file_cache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ def load(self):
3333
try:
3434
if os.path.isfile(self.file_name):
3535
if self.max_age > 0 and os.stat(self.file_name).st_mtime + self.max_age < time.clock():
36-
logging.info('Cache file expired: %s', file=self.file_name)
36+
logging.debug('Cache file expired: %s', file=self.file_name)
3737
os.remove(self.file_name)
3838
else:
39-
logging.info('Loading cache file: %s', self.file_name)
39+
logging.debug('Loading cache file: %s', self.file_name)
4040
self.data = get_file_json(self.file_name, throw_on_empty=False) or {}
4141
else:
42-
logging.info('Cache file does not exist: %s', self.file_name)
42+
logging.debug('Cache file does not exist: %s', self.file_name)
4343
except Exception as ex:
4444
logging.exception(ex)
4545
# file is missing or corrupt so attempt to delete it

vsts/vsts/vss_client.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ def _send_request(self, request, headers=None, content=None, **operation_config)
5050
"""
5151
if TRACE_ENV_VAR in os.environ and os.environ[TRACE_ENV_VAR] == 'true':
5252
print(request.method + ' ' + request.url)
53+
logging.debug('%s %s', request.method, request.url)
54+
logging.debug('Request content: %s', content)
5355
response = self._client.send(request=request, headers=headers,
5456
content=content, **operation_config)
57+
logging.debug('Response content: %s', response.content)
5558
if response.status_code < 200 or response.status_code >= 300:
5659
self._handle_error(request, response)
5760
return response
@@ -66,6 +69,14 @@ def _send(self, http_method, location_id, version, route_values=None,
6669
negotiated_version = self._negotiate_request_version(
6770
self._get_resource_location(location_id),
6871
version)
72+
73+
if version != negotiated_version:
74+
logging.info("Negotiated api version from '%s' down to '%s'. This means the client is newer than the server.",
75+
version,
76+
negotiated_version)
77+
else:
78+
logging.debug("Api version '%s'", negotiated_version)
79+
6980
# Construct headers
7081
headers = {'Content-Type': media_type + '; charset=utf-8',
7182
'Accept': 'application/json;api-version=' + negotiated_version}
@@ -139,14 +150,14 @@ def _get_resource_locations(self, all_host_types):
139150
# Next check for options cached on disk
140151
if not all_host_types and OPTIONS_FILE_CACHE[self.normalized_url]:
141152
try:
142-
logging.info('File cache hit for options on: %s', self.normalized_url)
153+
logging.debug('File cache hit for options on: %s', self.normalized_url)
143154
self._locations = self._base_deserialize.deserialize_data(OPTIONS_FILE_CACHE[self.normalized_url],
144155
'[ApiResourceLocation]')
145156
return self._locations
146157
except DeserializationError as ex:
147158
logging.exception(str(ex))
148159
else:
149-
logging.info('File cache miss for options on: %s', self.normalized_url)
160+
logging.debug('File cache miss for options on: %s', self.normalized_url)
150161

151162
# Last resort, make the call to the server
152163
options_uri = self._combine_url(self.config.base_url, '_apis')

vsts/vsts/vss_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ def _get_resource_areas(self, force=False):
7777
location_client = LocationClient(self.base_url, self._creds)
7878
if not force and RESOURCE_FILE_CACHE[location_client.normalized_url]:
7979
try:
80-
logging.info('File cache hit for resources on: %s', location_client.normalized_url)
80+
logging.debug('File cache hit for resources on: %s', location_client.normalized_url)
8181
self._resource_areas = location_client._base_deserialize.deserialize_data(RESOURCE_FILE_CACHE[location_client.normalized_url],
8282
'[ResourceAreaInfo]')
8383
return self._resource_areas
8484
except Exception as ex:
8585
logging.exception(str(ex))
8686
elif not force:
87-
logging.info('File cache miss for resources on: %s', location_client.normalized_url)
87+
logging.debug('File cache miss for resources on: %s', location_client.normalized_url)
8888
self._resource_areas = location_client.get_resource_areas()
8989
if self._resource_areas is None:
9090
# For OnPrem environments we get an empty collection wrapper.

0 commit comments

Comments
 (0)