--- old/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h 2018-09-14 00:35:51.443357400 +0530 +++ new/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.h 2018-09-14 00:35:48.875899900 +0530 @@ -54,6 +54,8 @@ void PrintJavaDebugString(char *msg, ...); void wPrintJavaDebugString(wchar_t *msg, ...); void wPrintDebugString(wchar_t *msg, ...); + void initializeFileLogger(); + void finalizeFileLogger(); #ifdef __cplusplus } --- old/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp 2018-09-14 00:36:05.228880300 +0530 +++ new/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp 2018-09-14 00:36:02.620549400 +0530 @@ -31,11 +31,32 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { #endif +static FILE* logFP = nullptr; +static char* filePath = nullptr; + +void initializeFileLogger() { + const char* var = "JAVA_ACCESSBRIDGE_LOGFILE"; + filePath = getenv(var); + if (filePath != nullptr) { + logFP = fopen(filePath, "w"); + if (logFP == nullptr) { + PrintDebugString("couldnot open file %s", filePath); + } + } +} + +void finalizeFileLogger() { + if (logFP) { + fclose(logFP); + logFP = nullptr; + } +} /** * print a GetLastError message */ @@ -89,6 +110,12 @@ printf("\r\n"); #endif #endif + if (logFP) { + va_list args; + va_start(args, msg); + fprintf(logFP, msg, args); + va_end(args); + } } /** @@ -109,6 +136,12 @@ printf("\r\n"); #endif #endif + if (logFP) { + va_list args; + va_start(args, msg); + fprintf(logFP, msg, args); + va_end(args); + } } /** * Wide version of the method to send debugging info to the appropriate place @@ -130,6 +163,12 @@ printf("\r\n"); #endif #endif + if (logFP) { + va_list args; + va_start(args, msg); + fwprintf(logFP, msg, args); + va_end(args); + } } /** @@ -152,6 +191,12 @@ printf("\r\n"); #endif #endif + if (logFP){ + va_list args; + va_start(args, msg); + fwprintf(logFP, msg, args); + va_end(args); + } } #ifdef __cplusplus } --- old/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp 2018-09-14 00:36:19.443319700 +0530 +++ new/src/jdk.accessibility/windows/native/libjavaaccessbridge/JavaAccessBridge.cpp 2018-09-14 00:36:16.473541800 +0530 @@ -165,6 +165,7 @@ JavaAccessBridge::JavaAccessBridge(HINSTANCE hInstance) { windowsInstance = hInstance; ATs = (AccessBridgeATInstance *) 0; + initializeFileLogger(); initBroadcastMessageIDs(); // get the unique to us broadcast msg. IDs } @@ -203,6 +204,7 @@ PrintDebugString(" finished deleting ATs"); PrintDebugString("GOODBYE CRUEL WORLD..."); + finalizeFileLogger(); }