strip sensitive information from logs
This commit is contained in:
@@ -305,6 +305,14 @@ namespace ANSCENTER {
|
||||
// Used by the ANSLIB_DBG macro below; can also be called directly to
|
||||
// gate expensive log-prep work.
|
||||
static int IsDebugViewEnabled();
|
||||
|
||||
// DebugView emit. Hands a pre-formatted "[Tag] body\n" line to
|
||||
// ANSCENTER_DebugLog inside the licensing DLL, which strips noise path
|
||||
// prefixes (e.g. C:\ProgramData\ANSCENTER\, C:\ProgramData\<profile>\)
|
||||
// before writing to OutputDebugStringA + stderr. Used by ANSLIB_DBG.
|
||||
// If the licensing DLL is unavailable, falls back to raw emit (no
|
||||
// filtering) so messages aren't lost.
|
||||
static void DebugLog(const char* preformattedLine);
|
||||
private:
|
||||
HMODULE dllHandle = nullptr;
|
||||
bool loaded = false;
|
||||
@@ -455,16 +463,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// ANSLIB_DBG: DebugView logging macro mirroring ANS_DBG, but the gate function
|
||||
// is dynamic-loaded inside ANSLIB.dll — consumers don't need to link or even
|
||||
// know about ANSLicensingSystem.dll. Output goes to BOTH OutputDebugStringA
|
||||
// (DebugView) and stderr, identical format to ANS_DBG: "[tag] formatted\n".
|
||||
// ANSLIB_DBG: DebugView logging macro mirroring ANS_DBG. Both the gate and the
|
||||
// emit path are dynamic-loaded inside ANSLIB.dll — consumers don't need to
|
||||
// link or even know about ANSLicensingSystem.dll. Output goes to BOTH
|
||||
// OutputDebugStringA (DebugView) and stderr, identical format to ANS_DBG:
|
||||
// "[tag] formatted\n".
|
||||
//
|
||||
// Noise path prefixes (e.g. C:\ProgramData\ANSCENTER\, C:\ProgramData\<profile>\)
|
||||
// are stripped centrally inside ANSCENTER_DebugLog before emit, so log lines
|
||||
// like "loaded from C:\ProgramData\Jh7O7nUe7vS\Models\Foo" appear as
|
||||
// "loaded from Models\Foo".
|
||||
//
|
||||
// Usage: ANSLIB_DBG("MyModule", "value=%d ptr=%p", val, ptr);
|
||||
//
|
||||
// Hot-path cost when gate is OFF: one indirect call (atomic load + branch
|
||||
// inside ANSLicensingSystem). When gate is ON: snprintf to a 1024-byte stack
|
||||
// buffer + OutputDebugStringA + fputs. No heap, no per-call allocation.
|
||||
// Hot-path cost when gate is OFF: one indirect call. When gate is ON: snprintf
|
||||
// to a 1024-byte stack buffer + cross-DLL call into ANSCENTER_DebugLog (which
|
||||
// scrubs prefixes then emits). No heap, no per-call allocation in the macro.
|
||||
#ifndef ANSCORE_DEBUGVIEW
|
||||
#define ANSCORE_DEBUGVIEW 1 // 1 = runtime-gated (default), 0 = hard-off (stripped)
|
||||
#endif
|
||||
@@ -473,9 +487,7 @@ public:
|
||||
if (::ANSCENTER::ANSLIB::IsDebugViewEnabled()) { \
|
||||
char _ansl_dbg_buf[1024]; \
|
||||
snprintf(_ansl_dbg_buf, sizeof(_ansl_dbg_buf), "[" tag "] " fmt "\n", ##__VA_ARGS__); \
|
||||
OutputDebugStringA(_ansl_dbg_buf); \
|
||||
fputs(_ansl_dbg_buf, stderr); \
|
||||
fflush(stderr); \
|
||||
::ANSCENTER::ANSLIB::DebugLog(_ansl_dbg_buf); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user