From 5fe08ae83e07aef2c7f9a56962d1ef28acf58b4d Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Sat, 22 Dec 2007 13:03:41 +0000 Subject: 2007-12-22 James Henstridge * psycopg/config.h: only print debug messages if psycopg_debug_enabled is true. * psycopg/psycopgmodule.c (init_psycopg): set psycopg_debug_enabled to true if the $PSYCOPG_DEBUG environment variable is set. --- psycopg/psycopgmodule.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'psycopg/psycopgmodule.c') diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 2c4be8c..26cc500 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -63,6 +63,10 @@ PyObject *pyPsycopgTzFixedOffsetTimezone = NULL; PyObject *psycoEncodings = NULL; +#ifdef PSYCOPG_DEBUG +int psycopg_debug_enabled = 0; +#endif + /** connect module-level function **/ #define psyco_connect_doc \ "connect(dsn, ...) -- Create a new database connection.\n\n" \ @@ -693,6 +697,11 @@ init_psycopg(void) PyObject *module, *dict; PyObject *c_api_object; +#ifdef PSYCOPG_DEBUG + if (getenv("PSYCOPG_DEBUG")) + psycopg_debug_enabled = 1; +#endif + Dprintf("initpsycopg: initializing psycopg %s", PSYCOPG_VERSION); /* initialize all the new types and then the module */ -- cgit v1.2.1