Commit 3b1f7b79 authored by juga  's avatar juga
Browse files

minor: Change info logs to debug or warning

when they contain sensitive information, eg. Web server or are too
verbose for the debug level.
Also add log to indicate when the main loop is actually started.
parent 4e7ad5d7
...@@ -377,7 +377,7 @@ def measure_relay(args, conf, destinations, cb, rl, relay): ...@@ -377,7 +377,7 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
# always fail when there's only one Web server. # always fail when there's only one Web server.
if not is_usable and \ if not is_usable and \
relay.is_exit_not_bad_allowing_port(dest.port): relay.is_exit_not_bad_allowing_port(dest.port):
log.info( log.debug(
"Exit %s (%s) that can't exit all ips, with exit policy %s, failed" "Exit %s (%s) that can't exit all ips, with exit policy %s, failed"
" to connect to %s via circuit %s (%s). Reason: %s. Trying again " " to connect to %s via circuit %s (%s). Reason: %s. Trying again "
"with it as entry.", relay.fingerprint, relay.nickname, "with it as entry.", relay.fingerprint, relay.nickname,
...@@ -575,6 +575,7 @@ def main_loop(args, conf, controller, relay_list, circuit_builder, result_dump, ...@@ -575,6 +575,7 @@ def main_loop(args, conf, controller, relay_list, circuit_builder, result_dump,
measured. measured.
""" """
log.info("Started the main loop to measure the relays.")
hbeat = Heartbeat(conf.getpath('paths', 'state_fname')) hbeat = Heartbeat(conf.getpath('paths', 'state_fname'))
# Set the time to wait for a thread to finish as the half of an HTTP # Set the time to wait for a thread to finish as the half of an HTTP
......
...@@ -207,12 +207,12 @@ class Destination: ...@@ -207,12 +207,12 @@ class Destination:
self._delta_seconds_retry *= factor or self._factor self._delta_seconds_retry *= factor or self._factor
if self._delta_seconds_retry > self._max_seconds_between_retries: if self._delta_seconds_retry > self._max_seconds_between_retries:
self._delta_seconds_retry = self._max_seconds_between_retries self._delta_seconds_retry = self._max_seconds_between_retries
log.info("Incremented the time to try destination %s past the " log.debug("Incremented the time to try destination %s past the "
"limit, capping it at %s hours.", "limit, capping it at %s hours.",
self.url, self._delta_seconds_retry / 60 / 60) self.url, self._delta_seconds_retry / 60 / 60)
else: else:
log.info("Incremented the time to try destination %s to %s hours.", log.debug("Incremented the time to try destination %s to %s "
self.url, self._delta_seconds_retry / 60 / 60) "hours.", self.url, self._delta_seconds_retry / 60 / 60)
def _get_last_try_in_seconds_ago(self): def _get_last_try_in_seconds_ago(self):
""" """
...@@ -250,23 +250,29 @@ class Destination: ...@@ -250,23 +250,29 @@ class Destination:
# Failed the last X consecutive times # Failed the last X consecutive times
if self._are_last_attempts_failures(): if self._are_last_attempts_failures():
# The log here will appear in all the the queued # The log here will appear in all the the queued relays and
# relays and threads. # threads.
log.warning("The last %s times the destination %s failed. " log.debug("The last %s times the destination %s failed. "
"It last ran %s seconds ago. "
"Disabled for %s seconds.",
self._max_num_failures, self.url,
self._get_last_try_in_seconds_ago(),
self._delta_seconds_retry)
log.warning("The last %s times a destination failed. "
"It last ran %s seconds ago. " "It last ran %s seconds ago. "
"Disabled for %s seconds.", "Disabled for %s seconds."
self._max_num_failures, self.url, "Please, add more destinations or increment the "
"number of maximum number of consecutive failures "
"in the configuration.",
self._max_num_failures,
self._get_last_try_in_seconds_ago(), self._get_last_try_in_seconds_ago(),
self._delta_seconds_retry) self._delta_seconds_retry)
log.warning("Please, add more destinations or increment the "
"number of maximum number of consecutive failures "
"in the configuration.")
# It was not used for a while and the last time it was used # It was not used for a while and the last time it was used
# was long ago, then try again # was long ago, then try again
if self._is_last_try_old_enough(): if self._is_last_try_old_enough():
log.info("The destination %s was not tried for %s seconds, " log.debug("The destination %s was not tried for %s seconds, "
"it is going to by tried again.", self.url, "it is going to by tried again.", self.url,
self._get_last_try_in_seconds_ago()) self._get_last_try_in_seconds_ago())
# Set the next time to retry higher, in case this attempt fails # Set the next time to retry higher, in case this attempt fails
self._increment_time_to_retry() self._increment_time_to_retry()
return True return True
......
...@@ -799,14 +799,17 @@ class ResultDump: ...@@ -799,14 +799,17 @@ class ResultDump:
msg += ". As exit." if as_exit else ". As entry." msg += ". As exit." if as_exit else ". As entry."
# When the error is that there are not more functional destinations. # When the error is that there are not more functional destinations.
if result.type == "error-destination": if result.type == "error-destination":
log.info("Shutting down because there are not functional " log.warning("Shutting down because there are not functional "
"destinations.") "destinations.")
# NOTE: Because this is executed in a thread, stop_threads can not # NOTE: Because this is executed in a thread, stop_threads can not
# be call from here, it has to be call from the main thread. # be call from here, it has to be call from the main thread.
# Instead set the singleton end event, that will call stop_threads # Instead set the singleton end event, that will call stop_threads
# from the main process. # from the main process.
settings.end_event.set() settings.end_event.set()
log.info(msg) # log every success/error measurement at debug level, to don't log the
# the Web server at info level and because there's already a
# heartbeat msg to indicate progress.
log.debug(msg)
def enter(self): def enter(self):
"""Main loop for the ResultDump thread. """Main loop for the ResultDump thread.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment