jenkins-bot has submitted this change and it was merged.
Change subject: Log requests served from the API cache
......................................................................
Log requests served from the API cache
There is no logging of requests successfully served from the API cache.
Typically threadedhttp logs the request, and api logs the response.
This change logs when CachedRequest does not need to submit the request,
logging the request parameters and the filename containing the cached data.
Change-Id: Ib4aea6b5d401121fedb2ae91b8869b1872d1b4db
---
M pywikibot/data/api.py
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
Nullzero: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index bb5c1cb..3ad6e8d 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -483,12 +483,16 @@
def _load_cache(self):
""" Return whether the cache can be used """
try:
- with open(self._cachefile_path(), 'rb') as f:
+ filename = self._cachefile_path()
+ with open(filename, 'rb') as f:
uniquedescr, self._data, self._cachetime = pickle.load(f)
assert(uniquedescr == str(self._uniquedescriptionstr()))
if self._expired(self._cachetime):
self._data = None
return False
+ pywikibot.debug(u"%s: cache hit (%s) for API request: %s"
+ % (self.__class__.__name__, filename, uniquedescr),
+ _logger)
return True
except IOError as e:
# file not found
--
To view, visit
https://gerrit.wikimedia.org/r/146045
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4aea6b5d401121fedb2ae91b8869b1872d1b4db
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>