Add debug and log functions to ANSLIB

This commit is contained in:
2026-04-26 06:59:42 +10:00
parent 947398483a
commit f81737ffc6
9 changed files with 585 additions and 23 deletions

View File

@@ -327,7 +327,36 @@ namespace ANSCENTER
std::cerr << "SPDLogger::LogFatal - Exception: " << e.what() << std::endl;
}
}
}
// C facade — exported with stable C linkage so ANSLIB (and any other consumer)
// can resolve via GetProcAddress without coupling to the C++ class ABI.
// Each call delegates to the process-wide SPDLogger singleton; the magic-static
// inside GetInstance handles thread-safe one-time initialisation.
extern "C" {
ANSLICENSE_API void ANSLogger_LogInfo(const char* src, const char* msg, const char* file, int line) {
try {
ANSCENTER::SPDLogger::GetInstance("ANSLIB").LogInfo(
src ? src : "", msg ? msg : "", file ? file : "", line);
} catch (...) {}
}
ANSLICENSE_API void ANSLogger_LogError(const char* src, const char* msg, const char* file, int line) {
try {
ANSCENTER::SPDLogger::GetInstance("ANSLIB").LogError(
src ? src : "", msg ? msg : "", file ? file : "", line);
} catch (...) {}
}
ANSLICENSE_API void ANSLogger_LogFatal(const char* src, const char* msg, const char* file, int line) {
try {
ANSCENTER::SPDLogger::GetInstance("ANSLIB").LogFatal(
src ? src : "", msg ? msg : "", file ? file : "", line);
} catch (...) {}
}
}
namespace ANSCENTER
{
EngineType ANSCENTER::ANSLicenseHelper::CheckHardwareInformation()
{
ANS_DBG("HWInfo", "CheckHardwareInformation: starting hardware detection");

View File

@@ -32,6 +32,15 @@
// filesystem check runs at most once per ~2 s.
extern "C" ANSLICENSE_API int ANSCENTER_IsDebugViewEnabled(void);
// C-linkage facade over SPDLogger so consumers can dynamic-load these via
// GetProcAddress without depending on the C++ class ABI. Each call routes to
// the process-wide SPDLogger singleton (thread-safe magic-static init).
extern "C" {
ANSLICENSE_API void ANSLogger_LogInfo (const char* src, const char* msg, const char* file, int line);
ANSLICENSE_API void ANSLogger_LogError(const char* src, const char* msg, const char* file, int line);
ANSLICENSE_API void ANSLogger_LogFatal(const char* src, const char* msg, const char* file, int line);
}
// ANS_DBG: Debug logging macro for DebugView (OutputDebugStringA on Windows).
// Usage: ANS_DBG("MyModule", "value=%d ptr=%p", val, ptr);
// Output: [MyModule] value=42 ptr=0x1234