-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Julien Anguenot wrote: > Hi, > > Gintautas Miliauskas wrote: >>> I think the shift to the oh-so-much-better Python logging module is >>> not complete. See this bit in ZEO/runzeo.py: >>> >>> def handle_sigusr2(self): >>> # TODO: this used to reinitialize zLOG. How do I achieve >>> # the same effect with Python's logging package? >>> # Should we restart as with SIGHUP? >>> log("received SIGUSR2, but it was not handled!", \ >>> level=logging.WARNING) >>> >>> svn blames Tim for the comment, and Gintautas for the actual logging >>> call change. >> Ouch. This migration took place such a long time ago that I barely >> remember it, much less the details. Apparently I did not know how to >> fix this then, and I don't really know now either. >> >> From this document it appears that zlog.initialize() would call some >> preset initializer function: >> http://ingo.fargonauten.de/epydoc/private/zLOG-module.html >> >> That means that somewhere else set_initializer() must have been >> called. I found this by Fred Drake: >> >> http://aspn.activestate.com/ASPN/Mail/Message/zope-Checkins/1926169 >> >> It looks like we should do some kind of a walk through all >> StreamHandlers and try to reopen their streams if possible. Do you >> think this makes sense? >> >> Shane Hathaway says in >> http://mail.python.org/pipermail/python-dev/2006-January/059578.html : >> >>> To be compatible with an external tool like logrotate, all a daemon >>> needs to do is close and reopen log files at about the same time log >>> rotation happens. To handle this use case, I suggest the logging >>> module needs a function named reopen(), which daemons can call upon >>> receipt of a signal. The reopen function will find all handlers with >>> open files and ask them to reopen. >> I take it that the logging module does not have such a function yet. >> >> Sorry for my refactoring causing problems. > > Thank you for the answer. For the moment, there is no hurry on my side > as I got a workaround. > > We could probably open a ticket in the collector for this. Should I do > it ?
Yes. I think the code for the external handler would look something like the following code:: import logging def rotate_logging_handlers(): """ Close and reopen all file-based handlers. """ logging._acquireLock() try: for h in logging._handlers.keys(): if isinstance(h, logging.FileHandler): h.flush() h.close() h.strm = open(handler.baseFilename, h.mode)) finally: logging._releaseLock() This example is for the Python 2.3 version of the 'logging' module; the Python 2.4 version uses a list, '_handlersList', instead of the '_handlers' dict. See the 'shutdown' functions in each for how to iterate over the list. Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 [EMAIL PROTECTED] Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v18.104.22.168 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEqVng+gerLs4ltQ4RAsVFAJ4oUGq2EMDn96mwYf8R28c5tWVIlACeKXQn osn+DaaXtcKCN1iZPZlxHQk= =gZUP -----END PGP SIGNATURE----- _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev