[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] minor: Change info logs to debug or warning



commit 3b1f7b79bfab9262567e487f0429635781f6fcab
Author: juga0 <juga@xxxxxxxxxx>
Date:   Tue Mar 2 17:21:15 2021 +0000

    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.
---
 sbws/core/scanner.py    |  3 ++-
 sbws/lib/destination.py | 34 ++++++++++++++++++++--------------
 sbws/lib/resultdump.py  |  9 ++++++---
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index f9ab1ce..c7dde75 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -377,7 +377,7 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
     # always fail when there's only one Web server.
     if not is_usable and \
             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"
             " to connect to %s via circuit %s (%s). Reason: %s. Trying again "
             "with it as entry.", relay.fingerprint, relay.nickname,
@@ -575,6 +575,7 @@ def main_loop(args, conf, controller, relay_list, circuit_builder, result_dump,
     measured.
 
     """
+    log.info("Started the main loop to measure the relays.")
     hbeat = Heartbeat(conf.getpath('paths', 'state_fname'))
 
     # Set the time to wait for a thread to finish as the half of an HTTP
diff --git a/sbws/lib/destination.py b/sbws/lib/destination.py
index 5330dbf..f007a7a 100644
--- a/sbws/lib/destination.py
+++ b/sbws/lib/destination.py
@@ -207,12 +207,12 @@ class Destination:
         self._delta_seconds_retry *= factor or self._factor
         if 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.",
                      self.url, self._delta_seconds_retry / 60 / 60)
         else:
-            log.info("Incremented the time to try destination %s to %s hours.",
-                     self.url, self._delta_seconds_retry / 60 / 60)
+            log.debug("Incremented the time to try destination %s to %s "
+                      "hours.", self.url, self._delta_seconds_retry / 60 / 60)
 
     def _get_last_try_in_seconds_ago(self):
         """
@@ -250,23 +250,29 @@ class Destination:
 
         # Failed the last X consecutive times
         if self._are_last_attempts_failures():
-            # The log here will appear in all the the queued
-            #  relays and threads.
-            log.warning("The last %s times the destination %s failed. "
+            # The log here will appear in all the the queued relays and
+            # threads.
+            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. "
-                        "Disabled for %s seconds.",
-                        self._max_num_failures, self.url,
+                        "Disabled for %s seconds."
+                        "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._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
             # was long ago, then try again
             if self._is_last_try_old_enough():
-                log.info("The destination %s was not tried for %s seconds, "
-                         "it is going to by tried again.", self.url,
-                         self._get_last_try_in_seconds_ago())
+                log.debug("The destination %s was not tried for %s seconds, "
+                          "it is going to by tried again.", self.url,
+                          self._get_last_try_in_seconds_ago())
                 # Set the next time to retry higher, in case this attempt fails
                 self._increment_time_to_retry()
                 return True
diff --git a/sbws/lib/resultdump.py b/sbws/lib/resultdump.py
index b287242..cc61bcc 100644
--- a/sbws/lib/resultdump.py
+++ b/sbws/lib/resultdump.py
@@ -799,14 +799,17 @@ class ResultDump:
             msg += ". As exit." if as_exit else ". As entry."
         # When the error is that there are not more functional destinations.
         if result.type == "error-destination":
-            log.info("Shutting down because there are not functional "
-                     "destinations.")
+            log.warning("Shutting down because there are not functional "
+                        "destinations.")
             # 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.
             # Instead set the singleton end event, that will call stop_threads
             # from the main process.
             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):
         """Main loop for the ResultDump thread.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits