commit 6bfbf1d788377126eb7505ee05864eb7fa58ba66
Author: Isis Lovecruft <isis(a)torproject.org>
Date: Sun Apr 21 05:40:14 2013 +0000
Add logfile as a config option and fix several bugs in the log.py.
* Fixed bugs due to several log functions attempting to use
"config.advanced.debug" and "config.basic.logfile". These are both located
under the config.main section.
* Add LICENSE header and encoding specification to log.py. (Yes, we need
these.)
* Add log.warn() function back in.
---
oonib.conf.example | 1 +
oonib/__init__.py | 4 ++--
oonib/log.py | 21 ++++++++++++++++-----
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/oonib.conf.example b/oonib.conf.example
index fb04f19..a4cb707 100644
--- a/oonib.conf.example
+++ b/oonib.conf.example
@@ -1,5 +1,6 @@
main:
report_dir: Null
+ logfile: Null
tor_datadir: Null
database_uri: 'sqlite://oonib_test_db.db'
db_threadpool_size: 10
diff --git a/oonib/__init__.py b/oonib/__init__.py
index 30ebd69..8ddad00 100644
--- a/oonib/__init__.py
+++ b/oonib/__init__.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
#
-# :authors: Arturo Filastò
-# :licence: see LICENSE
+# :authors: Arturo Filastò, Isis Lovecruft
+# :licence: see LICENSE for details
"""
In here we shall keep track of all variables and objects that should be
instantiated only once and be common to pieces of GLBackend code.
diff --git a/oonib/log.py b/oonib/log.py
index 64d82f1..14b203d 100644
--- a/oonib/log.py
+++ b/oonib/log.py
@@ -1,3 +1,11 @@
+# -*- encoding: utf-8 -*-
+#
+# :authors: Arturo Filastò, Isis Lovecruft
+# :licence: see LICENSE for details
+"""
+Twisted logger for the ooni backend system.
+"""
+
import sys
import os
import logging
@@ -28,16 +36,16 @@ def start(logfile=None, application_name="oonib"):
daily_logfile = None
if not logfile:
- logfile = config.basic.logfile
+ logfile = config.main.logfile
log_folder = os.path.dirname(logfile)
log_filename = os.path.basename(logfile)
daily_logfile = DailyLogFile(log_filename, log_folder)
- txlog.msg("Starting %s on %s (%s UTC)" % (application_name, otime.prettyDateNow(),
- otime.utcPrettyDateNow()))
-
+ txlog.msg("Starting %s on %s (%s UTC)" % (application_name,
+ otime.prettyDateNow(),
+ otime.utcPrettyDateNow()))
txlog.startLoggingWithObserver(LogWithNoPrefix(sys.stdout).emit)
txlog.addObserver(txlog.FileLogObserver(daily_logfile).emit)
@@ -48,9 +56,12 @@ def msg(msg, *arg, **kw):
print "%s" % msg
def debug(msg, *arg, **kw):
- if config.advanced.debug:
+ if config.main.debug:
print "[D] %s" % msg
+def warn(msg, *arg, **kw):
+ print "[W] %s" % msg
+
def err(msg, *arg, **kw):
print "[!] %s" % msg