Re: [Quickfix-users] Built QuickFix app, where is the log?
Brought to you by:
orenmnero
From: DA S. A. <ada...@ca...> - 2010-01-11 07:57:36
|
Hi, 1) The logs are in the directory/file you specified into your conf files : [DEFAULT] ConnectionType=initiator FileStorePath=./store FileLogPath=./log ............ ==> FileLogPath 2) The loop is supposed to wait for something happen and then exit the application. In your case you are consuming almost all CPU! You can put at least a sleep(1second) to avoid CPU overload, and when something become true/false the loop exit : loop = true; ............. while( loop ) { // ...... // sleep 1 second // ...... if( event == exitEvent ) { loop = false; } } I use to put waiting on system signals : .................. for( ; ; ) { int signal = wait_for_terminate_request( ); if( signal == SIGUSR1 ) { break; } else { // Do/log something // sleep 1 second } } ................ int wait_for_terminate_request( ) { sigset_t sset; sigemptyset( &sset ); sigaddset( &sset, SIGINT ); sigaddset( &sset, SIGQUIT ); sigaddset( &sset, SIGTERM ); sigaddset( &sset, SIGUSR1 ); sigprocmask( SIG_BLOCK, &sset, NULL ); int sig; if( sigwait( &sset, &sig ) == 0 ) return sig; // Signal number. return -1; // Error. } In your terminal just type 'kill -10 myappPID' and it will exit gracefully. 3) Do not 'get' fields directly, you could have exceptions... You should test if the field is here and then pick it : if( message.isSetField( FIX::FIELD::ClOrdID ) ) message.get( clordid ); or for header fields : if( message.getHeader( ).isSetField( FIX::FIELD::DeliverToCompID ) ) message.getHeader( ).get( delivertocompid ); Antonio. Le 09/01/2010 09:33, gtsafas a écrit : > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > > I built a quickfix app using pretty much the example from the site > > I had a few questions as I am new to both c++ and quickfix, hopefully > someone can help me. > > What should be going inside the while loop? > I see the store directory get created but where is my log getting created? > Do I have to do anything special to receive drop copies? > > Code below, > > Initiator.cpp > > #include "/opt/quickfix/include/quickfix/FileStore.h" > #include "/opt/quickfix/include/quickfix/FileLog.h" > #include "/opt/quickfix/include/quickfix/SocketInitiator.h" > #include "/opt/quickfix/include/quickfix/SessionSettings.h" > #include "/home/gt/SCRIPTS/GT-fix/MYAPP.h" > #include <string> > #include <iostream> > #include <fstream> > > int main( int argc, char** argv ) > { > > try > { > > if ( argc < 2 ) return 1; > std::string file = argv[1]; > > FIX::SessionSettings settings( file ); > > Application application; > FIX::FileStoreFactory storeFactory(settings); > FIX::ScreenLogFactory logFactory(settings); > FIX::SocketInitiator initiator(application, storeFactory, settings, > logFactory); > > initiator.start(); > while ( true ) > { > std::cout << "CONNECTED" << std::endl; > } > initiator.stop(); > return 0; > } > catch ( std::exception & e ) > { > std::cout << e.what() << std::endl; > return 1; > } > } > > > MYAPP.cpp > > #include "/home/gt/SCRIPTS/GT-fix/ROSNAPP.h" > #include "/opt/quickfix/include/quickfix/Session.h" > #include "/opt/quickfix/include/quickfix/MessageCracker.h" > > void Application::onLogon( const FIX::SessionID& sessionID ) {} > > void Application::onLogout( const FIX::SessionID& sessionID ) {} > > > void Application::fromApp( const FIX::Message& message, > const FIX::SessionID& sessionID ) > throw( FIX::FieldNotFound, FIX::IncorrectDataFormat, > FIX::IncorrectTagValue, FIX::UnsupportedMessageType ) > { > crack(message, sessionID); > } > > void Application::onMessage( const FIX42::NewOrderSingle& message, const > FIX::SessionID& ) > { > FIX::ClOrdID clOrdID; > FIX::ClearingAccount clearingAccount; > > message.get(clOrdID); > message.get(clearingAccount); > } > > /* void Application::onMessage( const FIX41::NewOrderSingle& message, > const FIX::SessionID& ) > { > FIX::ClOrdID clOrdID; > message.get(clOrdID); > > // compile time error!! field not defined in FIX41 > FIX::ClearingAccount clearingAccount; > message.get(clearingAccount); > } > > void Application::onMessage( const FIX42::OrderCancelRequest& message, > const FIX::SessionID& ) > { > FIX::ClOrdID clOrdID; > message.get(clOrdID); > > // compile time error!! field not defined for OrderCancelRequest > FIX::Price price; > message.get(price); > } > */ > > > |