[Pkg-privacy-commits] [obfsproxy] 126/353: Log exceptions to logfiles.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository obfsproxy.
commit 5d3573ec9afd3d549f2203bcc0f55d86324f7659
Author: George Kadianakis <desnacked at riseup.net>
Date: Tue Feb 26 16:33:54 2013 +0200
Log exceptions to logfiles.
---
ChangeLog | 3 +++
obfsproxy/common/log.py | 12 ++++++++++--
obfsproxy/pyobfsproxy.py | 11 ++++++++++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index be2cd7d..63a006c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Changes in version 0.0.3 - ??
+ - Add support for logging exceptions to logfiles.
+
Changes in version 0.0.2 - 2013-02-17
- Add some more files to the MANIFEST.in.
diff --git a/obfsproxy/common/log.py b/obfsproxy/common/log.py
index 0bec25d..bb30296 100644
--- a/obfsproxy/common/log.py
+++ b/obfsproxy/common/log.py
@@ -1,8 +1,9 @@
"""obfsproxy logging code"""
-
import logging
import sys
+from twisted.python import log
+
def get_obfslogger():
""" Return the current ObfsLogger instance """
return OBFSLOGGER
@@ -20,7 +21,10 @@ class ObfsLogger(object):
def __init__(self):
- self.safe_logging = True
+ self.safe_logging = True
+
+ observer = log.PythonLoggingObserver('obfslogger')
+ observer.start()
# Create the default log handler that logs to stdout.
self.obfslogger = logging.getLogger('obfslogger')
@@ -104,6 +108,10 @@ class ObfsLogger(object):
self.obfslogger.critical(msg, *args, **kwargs)
+ def exception(self, msg, *args, **kwargs):
+ """ Class wrapper around exception logging method """
+
+ self.obfslogger.exception(msg, *args, **kwargs)
""" Global variable that will track our Obfslogger instance """
OBFSLOGGER = ObfsLogger()
diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
index 6a3158a..8a742fb 100755
--- a/obfsproxy/pyobfsproxy.py
+++ b/obfsproxy/pyobfsproxy.py
@@ -101,7 +101,8 @@ def consider_cli_args(args):
# managed proxies without a logfile must not log at all.
log.disable_logs()
-def run():
+def pyobfsproxy():
+ """Actual pyobfsproxy entry-point."""
parser = set_up_cli_parsing()
args = parser.parse_args()
@@ -131,5 +132,13 @@ def run():
do_external_mode(args)
+def run():
+ """Fake entry-point so that we can log unhandled exceptions."""
+ try:
+ pyobfsproxy()
+ except Exception, e:
+ log.exception(e)
+ raise
+
if __name__ == '__main__':
run()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git
More information about the Pkg-privacy-commits
mailing list