[Buildbot-devel] Output to stdout, too?

Brian Warner warner-buildbot at lothar.com
Sun Oct 2 23:35:57 UTC 2005


> Is there any hope or dream of making buildbot also dump logs to stdout
> as well as to the logfile?

Hm. I'm not sure what is available under windows, but if it were under Unix
then the approach I'd take is to run twistd by hand and add a '--logfile=-'
argument, which will cause it to log to stdout *instead of* to a twistd.log
file. Then I'd pipe that into something like /bin/tee to send it to both a
file and to the console window.

When you run 'buildbot start DIR' (under windows), internally it just moves
to DIR and then runs:

 twistd --no_save --logfile=twisted.log --python=buildbot.tac --reactor=win32

So you could just change the --logfile argument and run that command
yourself.

Now, if you don't have something like 'tee' on windows, and you want to have
that functionality implemented inside buildbot itself.. well, the approach
I'd take there is to add some code to buildbot.tac that will register an
extra log observer. (note that this is a Twisted thing, not a
buildbot-specific thing, it's just that buildbot.tac is a convenient place to
do the registration):

---- start buildbot.tac
[existing setup code, which creates the 'application' instance]

def printLogMessage(msgdict):
    print msgdict['message']
from twisted.python import log
log.addObserver(printLogMessage)

---- end buildbot.tac

(actually, printLogMessage should be a little bit more complicated than
that.. look at twisted/python/log.py in FileLogObserver.emit to see what log
observers are supposed to implement).

By registering a second LogObserver, each log message will go to stdout as
well as the file.

If you're seeing problems with log rotation under windows, please consider
filing a bug in the Twisted bug tracker, http://twistedmatrix.com/bugs/ ,
since that's the best way to address this problem long-term.

hope that helps,
 -Brian




More information about the devel mailing list