mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
2007-12-22 James Henstridge <james@jamesh.id.au>
* 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.
This commit is contained in:
parent
f3e74d2c48
commit
5fe08ae83e
|
@ -1,3 +1,12 @@
|
||||||
|
2007-12-22 James Henstridge <james@jamesh.id.au>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2007-12-21 Federico Di Gregorio <fog@initd.org>
|
2007-12-21 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* Applied win32 patch from Jason Erickson.
|
* Applied win32 patch from Jason Erickson.
|
||||||
|
|
|
@ -23,11 +23,16 @@
|
||||||
#define PSYCOPG_CONFIG_H 1
|
#define PSYCOPG_CONFIG_H 1
|
||||||
|
|
||||||
/* debug printf-like function */
|
/* debug printf-like function */
|
||||||
|
#ifdef PSYCOPG_DEBUG
|
||||||
|
extern int psycopg_debug_enabled;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( __GNUC__) && !defined(__APPLE__)
|
#if defined( __GNUC__) && !defined(__APPLE__)
|
||||||
#ifdef PSYCOPG_DEBUG
|
#ifdef PSYCOPG_DEBUG
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define Dprintf(fmt, args...) \
|
#define Dprintf(fmt, args...) \
|
||||||
|
if (!psycopg_debug_enabled) ; else \
|
||||||
fprintf(stderr, "[%d] " fmt "\n", (int) getpid() , ## args)
|
fprintf(stderr, "[%d] " fmt "\n", (int) getpid() , ## args)
|
||||||
#else
|
#else
|
||||||
#define Dprintf(fmt, args...)
|
#define Dprintf(fmt, args...)
|
||||||
|
@ -38,6 +43,10 @@
|
||||||
static void Dprintf(const char *fmt, ...)
|
static void Dprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
if (!psycopg_debug_enabled)
|
||||||
|
return;
|
||||||
|
printf("[%d] ", (int) getpid());
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vprintf(fmt, ap);
|
vprintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
|
@ -63,6 +63,10 @@ PyObject *pyPsycopgTzFixedOffsetTimezone = NULL;
|
||||||
|
|
||||||
PyObject *psycoEncodings = NULL;
|
PyObject *psycoEncodings = NULL;
|
||||||
|
|
||||||
|
#ifdef PSYCOPG_DEBUG
|
||||||
|
int psycopg_debug_enabled = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** connect module-level function **/
|
/** connect module-level function **/
|
||||||
#define psyco_connect_doc \
|
#define psyco_connect_doc \
|
||||||
"connect(dsn, ...) -- Create a new database connection.\n\n" \
|
"connect(dsn, ...) -- Create a new database connection.\n\n" \
|
||||||
|
@ -693,6 +697,11 @@ init_psycopg(void)
|
||||||
PyObject *module, *dict;
|
PyObject *module, *dict;
|
||||||
PyObject *c_api_object;
|
PyObject *c_api_object;
|
||||||
|
|
||||||
|
#ifdef PSYCOPG_DEBUG
|
||||||
|
if (getenv("PSYCOPG_DEBUG"))
|
||||||
|
psycopg_debug_enabled = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
Dprintf("initpsycopg: initializing psycopg %s", PSYCOPG_VERSION);
|
Dprintf("initpsycopg: initializing psycopg %s", PSYCOPG_VERSION);
|
||||||
|
|
||||||
/* initialize all the new types and then the module */
|
/* initialize all the new types and then the module */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user