--- old/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp 2018-09-14 14:36:08.236591500 +0530 +++ new/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp 2018-09-14 14:36:06.754643400 +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); + vfprintf(logFP, msg, args); + va_end(args); + } } /** @@ -109,6 +136,12 @@ printf("\r\n"); #endif #endif + if (logFP) { + va_list args; + va_start(args, msg); + vfprintf(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); + vfwprintf(logFP, msg, args); + va_end(args); + } } /** @@ -152,6 +191,12 @@ printf("\r\n"); #endif #endif + if (logFP){ + va_list args; + va_start(args, msg); + vfwprintf(logFP, msg, args); + va_end(args); + } } #ifdef __cplusplus }