durusmail: quixote-users: where do mod_python print statements go?
where do mod_python print statements go?
2001-10-12
2001-10-12
2001-10-12
2001-10-12
2001-10-12
2001-10-12
2001-10-15
2001-10-15
2001-10-15
2001-10-15
2001-10-15
2001-10-15
2001-10-15
where do mod_python print statements go?
Greg Ward
2001-10-12
On 12 October 2001, Ray Drew said:
> running quixote 0.41 on win nt4, apache 1.3, mod_python
>
> I can't work out where python print statements are going. The _q_index()
> print "debug..." statement prints to the debug file (specified in demo.conf)
> when I run the demo under cgi. I've  specified DEBUG_LOG in config.py but
> this doesn't seem to work. Do I have to change something else?

If debug logging works with a CGI driver script, then there's nothing
wrong with your config file.  Yes, DEBUG_LOG is all you need.

Erno, can you confirm that debug logging works with mod_python under
Unix?  This might be a mod_python thing, or might be a
mod_python-under-NT thing.

(Which reminds me, I really should finish getting mod_python running on
my development machine, so I can try it out myself...)

Ray, if you're curious enough to dig into this, the place to look is
quixote/publish.py, in the setup_logs() method.  It's pretty darn
simple:

        if self.config.debug_log is None:
            # If no debug log file is configured, debugging output goes
            # to the bit-bucket.
            sys.stdout = open('/dev/null', 'w')
        else:
            sys.stdout = open(self.config.debug_log, 'a', 1)

IOW, if Quixote fails to open the debug log, it should die with a
traceback on stderr.  You can confirm this by setting DEBUG_LOG to point
to something silly like "x:\fdsaf\dsafas\dfas\dfasd", and running as a
CGI script.  You should get a traceback in Apache's error log.
(Assuming Apache on NT works like it does on Unix, and logs the stderr
of CGI scripts to its error log.)  Try it again under mod_python and see
what happens.

Next, try applying this patch to publish.py:

--- publish.py  2001/10/09 21:38:15     1.99
+++ publish.py  2001/10/12 13:07:31
@@ -133,2 +133,6 @@

+        self.debug("entering setup_logs()")
+        self.debug("sys.stdout = %r" % sys.stdout)
+        self.debug("self.config.debug_log = %r" % self.config.debug_log)
+
         if self.config.debug_log is None:
@@ -139,2 +143,4 @@
             sys.stdout = open(self.config.debug_log, 'a', 1)
+
+        self.debug("stdout reassigned; now sys.stdout = %r" % sys.stdout)


This will write debugging info to stderr -- so set DEBUG_LOG back to
something sensible, and run demo.cgi while watching Apache's error log.
Do it with a CGI driver script first (because things work there), and
then again under mod_python.

        Greg
--
Greg Ward - software developer                gward@mems-exchange.org
MEMS Exchange                            http://www.mems-exchange.org


reply