The logger main application is an example that you can use to rebuild the logger application.
Building this example will create a duplicate of the logger execuable with a different name (e.g. loggerAppDIS.exe versus loggerDIS.exe). Because it is the same executable as the logger, the pre-built executable is excluded from the release.
The Qt Toolkit is required to build the logger application.
/******************************************************************************* ** Copyright (c) 1992-2010 VT MAK ** All rights reserved. *******************************************************************************/ #include <lgrApplication.h> #include <lgrPrint.h> #include <lgrExceptions.h> #include <vlutil/vlPrint.h> #include <vlutil/vlProcessControl.h> #include <QtGui/QApplication> #include <QtGui/QSplashScreen> #include <QtCore/QSettings> #include <QtGui/QFont> #include <QtCore/QDir> #include <lgrConsole.h> #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #ifdef _DEBUG #include <crtdbg.h> #endif #endif namespace MAKLogger { // QApplication override to allow drag and drop behavior. class DtLgrQApplication : public QApplication { public: DtLgrQApplication(int& argc ,char** argv = 0) : QApplication(argc,argv) { //Set Font. QDir dir("../data/config"); #ifndef _WIN32 QSettings::setPath(QSettings::NativeFormat,QSettings::UserScope,dir.absolutePath()); #endif QSettings settings; QString str = settings.value("/qt/logger_font").toString(); QFont font; if (! str.isNull() && ! str.isEmpty()) { font.fromString(str); QApplication::setFont(font); } } #ifdef _WIN32 virtual bool winEventFilter(MSG *msg, long *result) { DtLoggerApplication::WinEventFilterFunction func = DtLoggerApplication::winEventFilter(); if(func) { if(!func(msg,result)) { return FALSE; } } return QApplication::winEventFilter(msg,result); } #endif }; class DtSplashPrinter : public DtPrinter { public: DtSplashPrinter(QSplashScreen* screen) : myScreen(screen) { } virtual void write( const std::string &str, int notify_level) { if(str.length() == 0) return; std::string copy = str; int i = 0; while(( i = copy.find_last_of('\n')) > 0) { copy.erase(i); } myScreen->showMessage(copy.c_str()); qApp->processEvents(); } protected: QSplashScreen* myScreen; }; void run(int& argc,char** argv) { try { // Need to construct QApplication before a QPixmap DtLgrQApplication* aQpp = 0; QSplashScreen* splash = 0; DtSplashPrinter* splashPrinter = 0; bool showSplash = true; #ifndef _WIN32 showSplash = getenv("DISPLAY") != 0; #endif if(showSplash) { aQpp = new DtLgrQApplication(argc, argv); QPixmap pixmap("../data/images/SplashScreen_DataLogger.png"); splash = new QSplashScreen( pixmap ); splashPrinter = new DtSplashPrinter(splash); DtInfo.attachPrinter(splashPrinter); splash->show(); } MAKLogger::DtLoggerApplication app; // All config files are now named lgrConfig{protocol}.xml and are found in the bin dir #if DtHLA_1516_EVOLVED DtString configFile("lgrConfigHLA1516e.xml"); #elif DtHLA_1516 DtString configFile("lgrConfigHLA1516.xml"); #elif DtHLA DtString configFile("lgrConfigHLA13.xml"); #else DtString configFile("lgrConfigDIS.xml"); #endif app.initialize(argc,argv, configFile); if(splash) { DtInfo.detachPrinter(splashPrinter); delete splashPrinter; splash->hide(); delete splash; } app.run(); if(DtLgrPrinter::messageWillPrint(DtLgrPrinter::Verbose)) { DtLgrPrinter::verbose("Deleting qApp Loader."); if(aQpp) delete aQpp; } } catch(DtException& ex) { DtString msg = ex.what(); DtString indent = ">"; DtString message; const DtException* lastExcetion = &ex; while(lastExcetion) { DtString nlIndent("\n"); nlIndent += indent; message += indent + lastExcetion->what() + nlIndent + DtString("Thrown at: ") + lastExcetion->where() + nlIndent + DtString("\n"); indent = DtString("--") + indent; lastExcetion = lastExcetion->lastException(); } DtLgrPrinter::critical(DtString("Uncaught DtException\n" + message)); } catch(std::exception& stdex) { DtLgrPrinter::critical(DtString("Uncaught std::exception\n") + stdex.what()); } catch(...) { DtLgrPrinter::critical(DtString("Uncaught unknown exception\n")); } printf("\n"); fflush(stdout); } } #ifdef _WIN32 int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) #else int main( int __argc, char** __argv ) #endif { #ifdef _WIN32 #ifdef _DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); #endif #endif MAKLogger::run(__argc, __argv); if(MAKLogger::DtLgrPrinter::messageWillPrint(MAKLogger::DtLgrPrinter::Verbose)) { MAKLogger::DtLgrPrinter::verbose("Finished Execution."); } return 0; }