From d375779a2251e3efef31f43a303385093764ca85 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Wed, 10 Jan 2024 06:27:38 -0700 Subject: [PATCH] feat: add [pyodbc] and timestamp to tracing output makes debugging quite a bit easier. --- src/pyodbcdbg.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pyodbcdbg.cpp b/src/pyodbcdbg.cpp index 574ab863..05cd65fd 100644 --- a/src/pyodbcdbg.cpp +++ b/src/pyodbcdbg.cpp @@ -94,9 +94,19 @@ const char* CTypeName(SQLSMALLINT n) void DebugTrace(const char* szFmt, ...) { va_list marker; + + // Get the current time + time_t now = time(NULL); + struct tm* now_tm = localtime(&now); + + // Print the timestamp and prefix + printf("%04d-%02d-%02dT%02d:%02d:%02d [pyodbc] ", + now_tm->tm_year + 1900, now_tm->tm_mon + 1, now_tm->tm_mday, + now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec); + + // Print the formatted string va_start(marker, szFmt); vprintf(szFmt, marker); va_end(marker); } #endif -