JCCyC
JCCyC

Reputation: 16612

How can I get back web.py's stdout log when running under Apache/mod_wsgi?

I developed a web.py application and tested it a lot under stand-alone mode (running myapp.py from the command line) and its stdout output was much useful for debugging. Now I'm running it under Apache/mod_wsgi and lots of things don't work. For instance, my basic auth scheme, which used to work, always refuses the username/passwords it's given. The first thing I need is to be able to look at the debug messages I used to have. But the script's output is nowhere to be found.

How can I have "debug prints" again?

I don't want to ask about specific issues in my app until I have that much sorted out.

Upvotes: 1

Views: 1054

Answers (1)

User
User

Reputation: 14863

>>> class STDOUT(object):
    def __init__(self, next):
        self.next = next
        self.file = open('stdout.txt', 'w')
    def write(self, thing):
        self.file.write(thing)
        l.append(thing)
        self.next.write(thing)

>>> import sys
>>> s = STDOUT(sys.stdout)
>>> sys.stdout = s
>>> l = []
>>> print 4
4
>>> l
['4', '\n']

Upvotes: 1

Related Questions