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

[tor-commits] [ooni-probe/master] Refactor log file rename configuration to oconfig



commit e6ac93347a50096897de673a368a99c557f5cef7
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Tue Nov 6 15:51:29 2012 +0100

    Refactor log file rename configuration to oconfig
---
 ooni/oconfig.py   |    7 +++++++
 ooni/utils/log.py |   16 ++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/ooni/oconfig.py b/ooni/oconfig.py
new file mode 100644
index 0000000..96a1ee0
--- /dev/null
+++ b/ooni/oconfig.py
@@ -0,0 +1,7 @@
+from ooni.utils import Storage
+
+# XXX move this to an actual configuration file
+basic = Storage()
+advanced = Storage()
+
+advanced.debug = True
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index 6e99dc6..e93295a 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -11,22 +11,21 @@ from twisted.python import log as txlog
 from twisted.python.logfile import DailyLogFile
 
 from ooni.utils import otime
-## error on import with new __init__ file: 31/10/12
-from ooni import config
+from ooni import oconfig
 
 # XXX make this a config option
-log_file = "/tmp/ooniprobe.log"
+log_file = oconfig.basic.logfile
 
-log_folder = os.path.join('/', *log_file.split('/')[:-1])
-log_filename = log_file.split('/')[-1]
-daily_logfile = DailyLogFile(log_filename, log_folder)
+def start(log_file=log_file):
+    log_folder = os.path.join('/', *log_file.split('/')[:-1])
+    log_filename = log_file.split('/')[-1]
+    daily_logfile = DailyLogFile(log_filename, log_folder)
 
-def start():
     txlog.msg("Starting OONI on %s (%s UTC)" %  (otime.prettyDateNow(),
                                                  otime.utcPrettyDateNow()))
     logging.basicConfig()
     python_logging = txlog.PythonLoggingObserver()
-    if config.advanced.debug:
+    if oconfig.advanced.debug:
         python_logging.logger.setLevel(logging.DEBUG)
     else:
         python_logging.logger.setLevel(logging.INFO)
@@ -49,3 +48,4 @@ def err(msg, *arg, **kw):
 
 def exception(*msg):
     logging.exception(msg)
+



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