summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2006-09-01 07:12:23 +0000
committerFederico Di Gregorio <fog@initd.org>2006-09-01 07:12:23 +0000
commit38cf5f45207e05632d0840efccede4b14f16af78 (patch)
tree30aaf93576c7ab30aed88cf2a8aab3cf5286362e
parentbe9822801f0b61adbbdb5af52e938d61f372678a (diff)
downloadpsycopg2-38cf5f45207e05632d0840efccede4b14f16af78.tar.gz
Logging patch from Charlie.
-rw-r--r--ChangeLog6
-rw-r--r--lib/pool.py16
2 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3040328..fb1e8a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* Release 2.0.4.
diff --git a/lib/pool.py b/lib/pool.py
index b51d255..0468db6 100644
--- a/lib/pool.py
+++ b/lib/pool.py
@@ -19,11 +19,27 @@ This module implements thread-safe (and not) connection pools.
import psycopg2
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
def dbg(*args):
LOG('ZPsycopgDA', DEBUG, "",
' '.join([str(x) for x in args])+'\n')
LOG('ZPsycopgDA', INFO, "Installed", "Logging using Zope's zLOG\n")
+
except:
import sys
def dbg(*args):