diff -Nacr a/mylog.c b/mylog.c *** a/mylog.c Fri Apr 15 22:11:34 2016 --- b/mylog.c Wed May 25 17:34:14 2016 *************** *** 108,114 **** #elif defined(POSIX_MULTITHREAD_SUPPORT) static pthread_mutex_t qlog_cs, mylog_cs; #endif /* WIN_MULTITHREAD_SUPPORT */ - static int force_log = 0; static int mylog_on = 0, qlog_on = 0; #if defined(WIN_MULTITHREAD_SUPPORT) --- 108,113 ---- *************** *** 140,162 **** #define DELETE_MYLOG_CS #endif /* WIN_MULTITHREAD_SUPPORT */ - #ifdef MY_LOG #define MYLOGFILE "mylog_" #ifndef WIN32 #define MYLOGDIR "/tmp" #else #define MYLOGDIR "c:" #endif /* WIN32 */ - #endif /* MY_LOG */ - #ifdef Q_LOG #define QLOGFILE "psqlodbc_" #ifndef WIN32 #define QLOGDIR "/tmp" #else #define QLOGDIR "c:" #endif /* WIN32 */ - #endif /* QLOG */ int get_mylog(void) --- 139,157 ---- *************** *** 193,200 **** mylog_on = 0; else if (globals.debug > 0) mylog_on = globals.debug; - else - mylog_on = force_log; if (qlog_onoff) qlog_on_count += cnopen; else --- 188,193 ---- *************** *** 205,212 **** qlog_on = 0; else if (globals.commlog > 0) qlog_on = globals.commlog; - else - qlog_on = force_log; LEAVE_QLOG_CS; LEAVE_MYLOG_CS; } --- 198,203 ---- *************** *** 214,226 **** #ifdef WIN32 #define LOGGING_PROCESS_TIME #include - #define PODBCLOGDIR "C:\\podbclog" #endif /* WIN32 */ #ifdef LOGGING_PROCESS_TIME #include static DWORD start_time = 0; #endif /* LOGGING_PROCESS_TIME */ - #ifdef MY_LOG static FILE *MLOGFP = NULL; static void MLOG_open() --- 205,215 ---- *************** *** 235,252 **** { generate_homefile(MYLOGFILE, filebuf); MLOGFP = fopen(filebuf, PG_BINARY_A); - if (!MLOGFP) - { - generate_filename("C:\\podbclog", MYLOGFILE, filebuf); - MLOGFP = fopen(filebuf, PG_BINARY_A); - #ifdef WIN32 - if (!MLOGFP) - { - if (0 == _mkdir(PODBCLOGDIR)) - MLOGFP = fopen(filebuf, PG_BINARY_A); - } - #endif /* WIN32 */ - } } if (MLOGFP) setbuf(MLOGFP, NULL); --- 224,229 ---- *************** *** 295,345 **** LEAVE_MYLOG_CS; GENERAL_ERRNO_SET(gerrno); } - DLL_DECLARE void - forcelog(const char *fmt,...) - { - static BOOL force_on = TRUE; - va_list args; - int gerrno = GENERAL_ERRNO; - - if (!force_on) - return; - - ENTER_MYLOG_CS; - va_start(args, fmt); - - if (!MLOGFP) - { - MLOG_open(); - if (!MLOGFP) - force_on = FALSE; - } - if (MLOGFP) - { - #ifdef WIN_MULTITHREAD_SUPPORT - #ifdef WIN32 - time_t ntime; - char ctim[128]; - - time(&ntime); - strcpy(ctim, ctime(&ntime)); - ctim[strlen(ctim) - 1] = '\0'; - fprintf(MLOGFP, "[%d.%d(%s)]", GetCurrentProcessId(), GetCurrentThreadId(), ctim); - #endif /* WIN32 */ - #endif /* WIN_MULTITHREAD_SUPPORT */ - #if defined(POSIX_MULTITHREAD_SUPPORT) - fprintf(MLOGFP, "[%lu]", pthread_self()); - #endif /* POSIX_MULTITHREAD_SUPPORT */ - vfprintf(MLOGFP, fmt, args); - } - va_end(args); - LEAVE_MYLOG_CS; - GENERAL_ERRNO_SET(gerrno); - } static void mylog_initialize(void) { INIT_MYLOG_CS; - mylog_on = force_log; } static void mylog_finalize(void) { --- 272,280 ---- *************** *** 351,363 **** } DELETE_MYLOG_CS; } - #else - static void mylog_initialize(void) {} - static void mylog_finalize(void) {} - #endif /* MY_LOG */ - #ifdef Q_LOG static FILE *QLOGFP = NULL; void qlog(char *fmt,...) --- 286,293 ---- *************** *** 407,413 **** static void qlog_initialize(void) { INIT_QLOG_CS; - qlog_on = force_log; } static void qlog_finalize(void) { --- 337,342 ---- *************** *** 419,428 **** } DELETE_QLOG_CS; } - #else - static void qlog_initialize(void) {} - static void qlog_finalize(void) {} - #endif /* Q_LOG */ void InitializeLogging(void) { --- 348,353 ---- diff -Nacr a/mylog.h b/mylog.h *** a/mylog.h Fri Apr 15 22:11:34 2016 --- b/mylog.h Wed May 25 17:34:11 2016 *************** *** 32,88 **** #ifdef __cplusplus extern "C" { #endif - /* Uncomment MY_LOG define to compile in the mylog() statements. - Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI - portion of the registry. You may have to manually add this key. - This logfile is intended for development use, not for an end user! - */ - #define MY_LOG - - /* Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog). - This logfile contains serious log statements that are intended for an - end user to be able to read and understand. It is controlled by the - 'CommLog' flag in the ODBCINST.INI portion of the registry (see above), - which is manipulated on the setup/connection dialog boxes. - */ - #define Q_LOG - - #ifdef MY_LOG DLL_DECLARE void mylog(const char *fmt,...); - DLL_DECLARE void forcelog(const char *fmt,...); #define inolog if (get_mylog() > 1) mylog /* for really temporary debug */ - #else /* MY_LOG */ - #ifndef WIN32 - #define mylog(args...) /* GNU convention for variable arguments */ - #define forcelog(args...) /* GNU convention for variable arguments */ - #define inolog(args...) /* GNU convention for variable arguments */ - #else - #define _DUMMY_LOG_IMPL_ - static void DumLog(const char *fmt,...) {} - #define mylog if (0) DumLog /* mylog */ - #define forcelog if (0) DumLog /* forcelog */ - #define inolog if (0) DumLog /* inolog */ - #endif /* WIN32 */ - #endif /* MY_LOG */ - - #ifdef Q_LOG extern void qlog(char *fmt,...); #define inoqlog if (get_qlog() > 1) qlog /* for really temporary debug */ - #else - #ifndef WIN32 - #define qlog(args...) /* GNU convention for variable arguments */ - #define inoqlog(args...) /* GNU convention for variable arguments */ - #else - #ifndef _DUMMY_LOG_IMPL_ - #define _DUMMY_LOG_IMPL_ - static void DumLog(const char *fmt,...) {} - #endif /* _DUMMY_LOG_IMPL_ */ - #define qlog if (0) DumLog /* qlog */ - #define inoqlog if (0) DumLog /* inoqlog */ - #endif /* WIN32 */ - #endif /* QLOG */ int get_qlog(void); int get_mylog(void); --- 32,43 ----