You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. diff --git a/obfsproxy/common/log.py b/obfsproxy/common/log.py
  2. index bb30296..79193d2 100644
  3. --- a/obfsproxy/common/log.py
  4. +++ b/obfsproxy/common/log.py
  5. @@ -1,5 +1,6 @@
  6. """obfsproxy logging code"""
  7. import logging
  8. +import logging.handlers
  9. import sys
  10. from twisted.python import log
  11. @@ -50,6 +51,18 @@ class ObfsLogger(object):
  12. self.obfslogger.addHandler(log_handler)
  13. + def set_syslog(self, progname):
  14. + """Set up our logger so that it starts logging to syslog instead."""
  15. +
  16. + # remove the default handler, and add the SysLogHandler:
  17. + self.obfslogger.removeHandler(self.default_handler)
  18. +
  19. + log_handler = logging.handlers.SysLogHandler(address='/dev/log')
  20. + formatter = logging.Formatter(progname + "[%(process)d]: %(message)s")
  21. + log_handler.setFormatter(formatter)
  22. +
  23. + self.obfslogger.addHandler(log_handler)
  24. +
  25. def set_log_severity(self, sev_string):
  26. """Update our minimum logging severity to 'sev_string'."""
  27. diff --git a/obfsproxy/pyobfsproxy.py b/obfsproxy/pyobfsproxy.py
  28. index 4a2faf6..eaf8a44 100755
  29. --- a/obfsproxy/pyobfsproxy.py
  30. +++ b/obfsproxy/pyobfsproxy.py
  31. @@ -42,6 +42,7 @@ def set_up_cli_parsing():
  32. parser.add_argument('-v', '--version', action='version', version=__version__)
  33. parser.add_argument('--log-file', help='set logfile')
  34. + parser.add_argument('--syslog', metavar='PROGNAME', help='use syslog')
  35. parser.add_argument('--log-min-severity',
  36. choices=['error', 'warning', 'info', 'debug'],
  37. help='set minimum logging severity (default: %(default)s)')
  38. @@ -110,6 +111,8 @@ def consider_cli_args(args):
  39. if args.log_file:
  40. log.set_log_file(args.log_file)
  41. + elif args.syslog:
  42. + log.set_syslog(args.syslog)
  43. if args.log_min_severity:
  44. log.set_log_severity(args.log_min_severity)
  45. if args.no_log: