[tor-commits] [ooni-probe/master] Added log.warn() and log.fail() functions to ooni's logger, and fixed the

isis at torproject.org isis at torproject.org
Tue Dec 18 05:53:46 UTC 2012


commit 037b4218e455b49240f1fe7a6826d03e60137765
Author: Isis Lovecruft <isis at torproject.org>
Date:   Tue Nov 27 14:22:21 2012 +0000

    Added log.warn() and log.fail() functions to ooni's logger, and fixed the
    deferred debugger in tcpsyn.setUp.
---
 nettests/bridge_reachability/tcpsyn.py |    4 ++--
 ooni/utils/log.py                      |   12 +++++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/nettests/bridge_reachability/tcpsyn.py b/nettests/bridge_reachability/tcpsyn.py
index 555fdef..dd7f494 100644
--- a/nettests/bridge_reachability/tcpsyn.py
+++ b/nettests/bridge_reachability/tcpsyn.py
@@ -79,8 +79,8 @@ class TCPFlagTest(nettest.NetTestCase):
             else:
                 log.msg("Using system default interface: %s" % iface)
                 self.interface = iface
-        if config.debug:
-            defer.setDebugging(on)
+        if config.advanced.debug:
+            defer.setDebugging('on')
 
     def addToDestinations(self, addr='0.0.0.0', port='443'):
         """
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index c751571..3b2b92a 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -49,6 +49,9 @@ def msg(msg, *arg, **kw):
 def debug(msg, *arg, **kw):
     txlog.msg(msg, logLevel=logging.DEBUG, *arg, **kw)
 
+def warn(msg, category=None, filename=None, lineno=None, *arg, **kw):
+    txlog.warnings.warn(msg, category, filename, lineno, *arg, **kw)
+
 def err(msg, *arg, **kw):
     txlog.err("Error: " + str(msg), logLevel=logging.ERROR, *arg, **kw)
 
@@ -60,7 +63,10 @@ def exception(msg):
 def exception(*msg):
     logging.exception(msg)
 
-def catcher(func):
+def fail(failure):
+    txlog.failure(failure)
+
+def catch(func):
     """
     Quick wrapper to add around test methods for debugging purposes,
     catches the given Exception. Use like so:
@@ -71,12 +77,12 @@ def catcher(func):
                 raise Exception("catch me no matter what I am")
         foo("baz")
     """
-    def _catcher(*args, **kwargs):
+    def _catch(*args, **kwargs):
         try:
             func(*args, **kwargs)
         except Exception, exc:
             exception(exc)
-    return _catcher
+    return _catch
 
 class LoggerFactory(object):
     """





More information about the tor-commits mailing list