[stem/master] Hook to disable trace logging for cache fetches

commit e378b22f7cd167cb66d9baf630858cec73f24b42 Author: Damian Johnson <atagar@torproject.org> Date: Sun Jan 31 14:06:09 2016 -0800 Hook to disable trace logging for cache fetches Cache hits generally aren't very interesting and can generate a lot of noise. Providing an option so callers can disable them. --- stem/control.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/stem/control.py b/stem/control.py index cecc48b..8918426 100644 --- a/stem/control.py +++ b/stem/control.py @@ -323,6 +323,8 @@ Listener = stem.util.enum.UppercaseEnum( 'CONTROL', ) +LOG_CACHE_FETCHES = True # provide trace level logging for cache hits + # Configuration options that are fetched by a special key. The keys are # lowercase to make case insensitive lookups easier. @@ -1104,7 +1106,8 @@ class Controller(BaseController): # if everything was cached then short circuit making the query if not params: - log.trace('GETINFO %s (cache fetch)' % ' '.join(reply.keys())) + if LOG_CACHE_FETCHES: + log.trace('GETINFO %s (cache fetch)' % ' '.join(reply.keys())) if is_multiple: return reply @@ -2118,7 +2121,9 @@ class Controller(BaseController): # if everything was cached then short circuit making the query if not lookup_params: - log.trace('GETCONF %s (cache fetch)' % ' '.join(reply.keys())) + if LOG_CACHE_FETCHES: + log.trace('GETCONF %s (cache fetch)' % ' '.join(reply.keys())) + return self._get_conf_dict_to_response(reply, default, multiple) try: @@ -2400,7 +2405,9 @@ class Controller(BaseController): service_dir_map = self._get_cache('hidden_service_conf') if service_dir_map is not None: - log.trace('GETCONF HiddenServiceOptions (cache fetch)') + if LOG_CACHE_FETCHES: + log.trace('GETCONF HiddenServiceOptions (cache fetch)') + return service_dir_map start_time = time.time()
participants (1)
-
atagar@torproject.org