Logging patch from Charlie.

This commit is contained in:
Federico Di Gregorio 2006-09-01 07:12:23 +00:00
parent be9822801f
commit 38cf5f4520
2 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2006-09-01 Federico Di Gregorio <fog@initd.org>
* lib/pool.py: applied logging patch from Charlie Clark.
It will probably get a makeup and be moved to the top-level
module later.
2006-08-02 Federico Di Gregorio <fog@initd.org> 2006-08-02 Federico Di Gregorio <fog@initd.org>
* Release 2.0.4. * Release 2.0.4.

View File

@ -19,11 +19,27 @@ This module implements thread-safe (and not) connection pools.
import psycopg2 import psycopg2
try: try:
import logging
# do basic initialization if the module is not already initialized
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
# create logger object for psycopg2 module and sub-modules
_logger = logging.getLogger("psycopg2")
def dbg(*args):
_logger.debug("psycopg2", ' '.join([str(x) for x in args]))
try:
import App # does this make sure that we're running in Zope?
_logger.info("installed. Logging using Python logging module")
except:
_logger.debug("installed. Logging using Python logging module")
except ImportError:
from zLOG import LOG, DEBUG, INFO from zLOG import LOG, DEBUG, INFO
def dbg(*args): def dbg(*args):
LOG('ZPsycopgDA', DEBUG, "", LOG('ZPsycopgDA', DEBUG, "",
' '.join([str(x) for x in args])+'\n') ' '.join([str(x) for x in args])+'\n')
LOG('ZPsycopgDA', INFO, "Installed", "Logging using Zope's zLOG\n") LOG('ZPsycopgDA', INFO, "Installed", "Logging using Zope's zLOG\n")
except: except:
import sys import sys
def dbg(*args): def dbg(*args):