Re: ThreadedConnectionPool and Cherrypy
Daniele Varrazzo <[email protected]> Fri, 25 Jun 2010 13:16:30 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jun 25, 2010 at 11:00 AM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote: > So, probably, psycopg.pool is imported before other modules and the > other modules add handlers anyway. I'd say this is a psycopg bug that > being a library should not initialize the logging system. Will fix this > when I understand exactly what I library should do; Yep, organizing the logging system between libraries is tricky. I think the correct thing to do in libraries is just not to call basicConfig: use the desired logger objects and leave their configuration as a policy of the calling application. This is the guideline I usually adopt to get rid of duplicate lines in projects where loggings starts becoming messy. > in the meantime just > leave the comment in place. If Joe wants to avoid duplicate logging in his app without changing psycopg code (e.g. if he's using a system version) he may try to fool the logging system by one of: - if his application installs handlers on the root logger, he may ensure that logging init is performed before importing psycopg - if he's not using handlers on the root logger, he may install a no-op handler before importing psycopg, e.g. logging.basicConfig(stream=open(os.devnull, 'a')) - if he thinks basicConfig is not a good idea, he may monkeypatch it away before importing psycopg: logging.basicConfig = lambda **kwargs: None -- Daniele