[crossfire] Improving Python logging

Nicolas Weeger nicolas.weeger at laposte.net
Mon Jun 13 12:56:53 CDT 2011


Hello.



I've looked at how to have the Python errors go to the Crossfire log instead of 
stderr.


The culprit is PyErr_Print() on line 924 file cfpython.c, which dumps the error 
to stderr.


I looked at intercepting that, but it doesn't seem that easy, so I'm just 
dumping my findings here for now, if anyone wants to tackle that issue feel 
free :)


I see two options:

- use PyTraceBack_Print() after creating some StringIO object to hold the 
message, then convert back to a C-string (PyString_AsString probably) ; 
StringIO claims to have a C API, but I couldn't find any documentation

- shamelessly get code from 
http://svn.python.org/projects/python/tags/r20c1/Python/pythonrun.c (which has 
the source of PyErr_Print()) and adapt it to our use ; warning, the licence 
may not be compatible with GPL, check 
http://svn.python.org/projects/python/tags/r20c1/LICENSE and your local legal 
expert



Regards


Nicolas
-- 
Mon p'tit coin du web - http://nicolas.weeger.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://mailman.metalforge.org/pipermail/crossfire/attachments/20110613/eaf5a0d6/attachment.pgp>


More information about the crossfire mailing list