strip sensitive information from logs
This commit is contained in:
@@ -13,10 +13,12 @@ namespace ANSCENTER
|
||||
// pointers are write-once globals — concurrent reads are race-free.
|
||||
using ANSLogger_LogFnT = void(*)(const char*, const char*, const char*, int);
|
||||
using ANSCENTER_IsDbgEnFnT = int (*)(void);
|
||||
ANSLogger_LogFnT g_ANSLogger_LogInfo = nullptr;
|
||||
ANSLogger_LogFnT g_ANSLogger_LogError = nullptr;
|
||||
ANSLogger_LogFnT g_ANSLogger_LogFatal = nullptr;
|
||||
ANSCENTER_IsDbgEnFnT g_ANSCENTER_IsDebugViewEnabled = nullptr;
|
||||
using ANSCENTER_DebugLogFnT = void(*)(const char*);
|
||||
ANSLogger_LogFnT g_ANSLogger_LogInfo = nullptr;
|
||||
ANSLogger_LogFnT g_ANSLogger_LogError = nullptr;
|
||||
ANSLogger_LogFnT g_ANSLogger_LogFatal = nullptr;
|
||||
ANSCENTER_IsDbgEnFnT g_ANSCENTER_IsDebugViewEnabled = nullptr;
|
||||
ANSCENTER_DebugLogFnT g_ANSCENTER_DebugLog = nullptr;
|
||||
|
||||
// Pre-load all ANSCORE DLLs from the Shared folder using full paths.
|
||||
// This ensures the correct versions are loaded regardless of PATH order
|
||||
@@ -45,10 +47,11 @@ namespace ANSCENTER
|
||||
// Use GetModuleHandleA — the DLL is already in this process's module
|
||||
// list courtesy of the LoadLibraryA above, so refcount is unchanged.
|
||||
if (HMODULE lic = GetModuleHandleA("ANSLicensingSystem.dll")) {
|
||||
g_ANSLogger_LogInfo = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogInfo");
|
||||
g_ANSLogger_LogError = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogError");
|
||||
g_ANSLogger_LogFatal = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogFatal");
|
||||
g_ANSCENTER_IsDebugViewEnabled = (ANSCENTER_IsDbgEnFnT)GetProcAddress(lic, "ANSCENTER_IsDebugViewEnabled");
|
||||
g_ANSLogger_LogInfo = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogInfo");
|
||||
g_ANSLogger_LogError = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogError");
|
||||
g_ANSLogger_LogFatal = (ANSLogger_LogFnT) GetProcAddress(lic, "ANSLogger_LogFatal");
|
||||
g_ANSCENTER_IsDebugViewEnabled = (ANSCENTER_IsDbgEnFnT) GetProcAddress(lic, "ANSCENTER_IsDebugViewEnabled");
|
||||
g_ANSCENTER_DebugLog = (ANSCENTER_DebugLogFnT)GetProcAddress(lic, "ANSCENTER_DebugLog");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -288,6 +291,20 @@ namespace ANSCENTER
|
||||
PreloadSharedDllsOnce();
|
||||
return g_ANSCENTER_IsDebugViewEnabled ? g_ANSCENTER_IsDebugViewEnabled() : 0;
|
||||
}
|
||||
void ANSLIB::DebugLog(const char* preformattedLine) {
|
||||
PreloadSharedDllsOnce();
|
||||
if (!preformattedLine) return;
|
||||
if (g_ANSCENTER_DebugLog) {
|
||||
// Preferred path: licensing DLL applies the prefix scrubber and emits.
|
||||
g_ANSCENTER_DebugLog(preformattedLine);
|
||||
return;
|
||||
}
|
||||
// Fallback for environments where ANSLicensingSystem.dll is missing:
|
||||
// emit raw to DebugView + stderr without filtering. Better than dropping.
|
||||
OutputDebugStringA(preformattedLine);
|
||||
std::fputs(preformattedLine, stderr);
|
||||
std::fflush(stderr);
|
||||
}
|
||||
void ANSLIB::LogInfo(const char* src, const char* msg, const char* file, int line) {
|
||||
PreloadSharedDllsOnce();
|
||||
if (g_ANSLogger_LogInfo) g_ANSLogger_LogInfo(src, msg, file, line);
|
||||
|
||||
Reference in New Issue
Block a user