Support Get log events
This commit is contained in:
@@ -3052,3 +3052,44 @@ extern "C" ANSULT_API int ScanANSDevices(int timeoutMs, LStrHandle resultJson) {
|
||||
}
|
||||
catch (...) { return -1; }
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GetANSLoggerErrorEvents — read Error-level events from the ANSLogger source
|
||||
// in the Windows Application event log. Returns 1 on success (string may be
|
||||
// empty if no events match), 0 on internal failure.
|
||||
// `clearAfterRead != 0` triggers EvtClearLog on the entire Application
|
||||
// channel — see ANSUtilities.h header comment for caveats.
|
||||
// ---------------------------------------------------------------------------
|
||||
extern "C" ANSULT_API int GetANSLoggerErrorEventsCpp(int clearAfterRead, std::string& result) {
|
||||
ANS_DBG("ANSUTIL", "GetANSLoggerErrorEventsCpp: clearAfterRead=%d", clearAfterRead);
|
||||
try {
|
||||
result = ANSCENTER::ANSUtilities::GetANSLoggerErrorEvents(clearAfterRead != 0);
|
||||
return 1;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
ANS_DBG("ANSUTIL", "GetANSLoggerErrorEventsCpp threw: %s", e.what());
|
||||
result.clear();
|
||||
return 0;
|
||||
}
|
||||
catch (...) {
|
||||
ANS_DBG("ANSUTIL", "GetANSLoggerErrorEventsCpp threw unknown");
|
||||
result.clear();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" ANSULT_API int GetANSLoggerErrorEvents(int clearAfterRead, LStrHandle result) {
|
||||
ANS_DBG("ANSUTIL", "GetANSLoggerErrorEvents: clearAfterRead=%d", clearAfterRead);
|
||||
if (!result) return -1;
|
||||
try {
|
||||
std::string s;
|
||||
GetANSLoggerErrorEventsCpp(clearAfterRead, s);
|
||||
int size = static_cast<int>(s.size());
|
||||
MgErr error = DSSetHandleSize(result, sizeof(int32) + size * sizeof(uChar));
|
||||
if (error != noErr) return -2;
|
||||
(*result)->cnt = size;
|
||||
if (size > 0) memcpy((*result)->str, s.data(), size);
|
||||
return 1;
|
||||
}
|
||||
catch (...) { return -1; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user