[Twisted-Python] Logging to stdout from trial

Jonathan Lange jml at ids.org.au
Sat Aug 9 11:26:00 MDT 2003


The trial script takes a --logfile option, and writes all logs to this file. If
you haven't noticed in the past, it's because it logs to test.log

Below is a patch that sets the logfile to sys.stdout if the logfile is given as
'-'. e.g. trial --logfile=- twisted.test.test_trial

I'd commit this but I know very little about twisted's logging, and I don't
know whether this solves the real problem or not.


Index: twisted/scripts/trial.py
===================================================================
RCS file: /cvs/Twisted/twisted/scripts/trial.py,v
retrieving revision 1.46
diff -u -r1.46 trial.py
--- twisted/scripts/trial.py    19 Jul 2003 21:36:49 -0000      1.46
+++ twisted/scripts/trial.py    9 Aug 2003 05:58:05 -0000
@@ -254,7 +254,10 @@
                print
                print x['format'] % x
        log.addObserver(seeWarnings)
-       log.startLogging(open(config['logfile'], 'a'), 0)
+       if config['logfile'] == '-':
+           log.startLogging(sys.stdout, 0)
+       else:
+           log.startLogging(open(config['logfile'], 'a'), 0)

     tbformat = config['tbformat']

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030810/19e5b7e4/attachment.sig>


More information about the Twisted-Python mailing list