~stefanor/ibid/google-380918

« back to all changes in this revision

Viewing changes to ibid/__init__.py

  • Committer: Michael Gorven
  • Date: 2009-05-26 13:53:05 UTC
  • mfrom: (640.1.1 twistd-logging-344270)
  • Revision ID: michael@gorven.za.net-20090526135305-bj777qqzwbjijmbe
Fix logging setup under twistd in Jaunty and Lenny.
https://code.launchpad.net/~mgorven/ibid/twistd-logging-344270/+merge/6790

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        options[key] = value
48
48
    options['base'] = dirname(options['config'])
49
49
 
 
50
    # Get Twisted to log to Python logging
 
51
    twisted.python.log.startLoggingWithObserver(twisted_log)
 
52
 
50
53
    # Undo Twisted logging's redirection of stdout and stderr
51
54
    sys.stdout = sys.__stdout__
52
55
    sys.stderr = sys.__stderr__
53
56
    logging.basicConfig(level=logging.INFO)
54
57
 
55
 
    # Get Twisted to log to Python logging
56
 
    for observer in twisted.python.log.theLogPublisher.observers:
57
 
        twisted.python.log.removeObserver(observer)
58
 
    twisted.python.log.addObserver(twisted_log)
59
 
 
60
58
    if not exists(options['config']):
61
59
        raise IbidException('Cannot find configuration file %s' % options['config'])
62
60