Logging.cpp shows how to create a handler to access logging events.It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
It can also be helpful to familiarize yourself with the NodeMapCallback example, as nodemap callbacks follow the same general procedure as events, but with a few less steps.
This example creates a user-defined class, LoggingEventHandlerImpl, that inherits from the Spinnaker class, LoggingEventHandler. The child class allows the user to define any properties, parameters, and the event itself while LoggingEventHandler allows the child class to appropriately interface with the Spinnaker SDK.
#include <iostream>
#include <sstream>
using namespace Spinnaker;
using namespace Spinnaker::GenApi;
using namespace Spinnaker::GenICam;
using namespace std;
{
{
cout << "--------Log Event Received----------" << endl;
cout << "Category: " << loggingEventDataPtr->GetCategoryName() << endl;
cout << "Priority Value: " << loggingEventDataPtr->GetPriority() << endl;
cout << "Priority Name: " << loggingEventDataPtr->GetPriorityName() << endl;
cout << "Timestmap: " << loggingEventDataPtr->GetTimestamp() << endl;
cout << "NDC: " << loggingEventDataPtr->GetNDC() << endl;
cout << "Thread: " << loggingEventDataPtr->GetThreadName() << endl;
cout << "Message: " << loggingEventDataPtr->GetLogMessage() << endl;
cout << "------------------------------------" << endl << endl;
}
};
{
cout << "Application build date: " << __DATE__ << " " << __TIME__ << endl << endl;
const LibraryVersion spinnakerLibraryVersion = system->GetLibraryVersion();
cout <<
"Spinnaker library version: " << spinnakerLibraryVersion.
major <<
"." << spinnakerLibraryVersion.
minor
<<
"." << spinnakerLibraryVersion.
type <<
"." << spinnakerLibraryVersion.
build << endl
<< endl;
system->RegisterLoggingEventHandler(loggingEventHandler);
unsigned int numCameras = camList.
GetSize();
cout << "Number of cameras detected: " << numCameras << endl << endl;
system->UnregisterLoggingEventHandler(loggingEventHandler);
system->ReleaseInstance();
cout << endl << "Done! Press Enter to exit..." << endl;
getchar();
return 0;
}