@@ -900,7 +900,6 @@ void spawnDevice(DeviceRef ref,
900900 gDeviceMetricsInfos .emplace_back (DeviceMetricsInfo{});
901901}
902902
903-
904903struct LogProcessingState {
905904 bool didProcessLog = false ;
906905 bool didProcessControl = true ;
@@ -1044,27 +1043,31 @@ bool processSigChild(DeviceInfos& infos)
10441043 return hasError;
10451044}
10461045
1047- void doDPLException (RuntimeErrorRef& e)
1046+ void doDPLException (RuntimeErrorRef& e, char const * processName )
10481047{
10491048 auto & err = o2::framework::error_from_ref (e);
10501049 if (err.maxBacktrace != 0 ) {
1051- LOG (ERROR ) << " Unhandled o2::framework::runtime_error reached the top of main, device shutting down."
1052- << " \n Reason: " << err.what
1053- << " \n Backtrace follow: \n " ;
1050+ LOGP (ERROR ,
1051+ " Unhandled o2::framework::runtime_error reached the top of main of {}, device shutting down."
1052+ " \n Reason: "
1053+ " \n Backtrace follow: \n " ,
1054+ processName, err.what );
10541055 backtrace_symbols_fd (err.backtrace , err.maxBacktrace , STDERR_FILENO );
10551056 } else {
1056- LOG (ERROR ) << " Unhandled o2::framework::runtime_error reached the top of main, device shutting down."
1057- << " \n Reason: " << err.what
1058- << " \n Recompile with DPL_ENABLE_BACKTRACE=1 to get more information." ;
1057+ LOGP (ERROR ,
1058+ " Unhandled o2::framework::runtime_error reached the top of main of {}, device shutting down."
1059+ " \n Reason: "
1060+ " \n Recompile with DPL_ENABLE_BACKTRACE=1 to get more information." ,
1061+ processName, err.what );
10591062 }
10601063}
10611064
1062- void doUnknownException (std::string const & s)
1065+ void doUnknownException (std::string const & s, char const * processName )
10631066{
10641067 if (s.empty ()) {
1065- LOG (ERROR ) << " Unknown error while setting up workflow. " ;
1068+ LOGP (ERROR , " unknown error while setting up workflow in {}. " , processName) ;
10661069 } else {
1067- LOG (ERROR ) << " error while setting up workflow: " << s ;
1070+ LOGP (ERROR , " error while setting up workflow in {}: {} " , processName, s) ;
10681071 }
10691072}
10701073
@@ -1483,17 +1486,17 @@ int runStateMachine(DataProcessorSpecs const& workflow,
14831486
14841487 // This should expand nodes so that we can build a consistent DAG.
14851488 } catch (std::runtime_error& e) {
1486- std::cerr << " Invalid workflow: " << e.what () << std::endl ;
1489+ LOGP ( ERROR , " invalid workflow in {}: {} " , driverInfo. argv [ 0 ], e.what ()) ;
14871490 return 1 ;
14881491 } catch (o2::framework::RuntimeErrorRef ref) {
14891492 auto & err = o2::framework::error_from_ref (ref);
14901493#ifdef DPL_ENABLE_BACKTRACE
14911494 backtrace_symbols_fd (err.backtrace , err.maxBacktrace , STDERR_FILENO );
14921495#endif
1493- std::cerr << " Invalid workflow: " << err.what << std::endl ;
1496+ LOGP ( ERROR , " invalid workflow in {}: {} " , driverInfo. argv [ 0 ], err.what ) ;
14941497 return 1 ;
14951498 } catch (...) {
1496- std::cerr << " Unknown error while materialising workflow" ;
1499+ LOGP ( ERROR , " invalid workflow in {}: Unknown error while materialising workflow" , driverInfo. argv [ 0 ]) ;
14971500 return 1 ;
14981501 }
14991502 break ;
@@ -1580,7 +1583,7 @@ int runStateMachine(DataProcessorSpecs const& workflow,
15801583 driverInfo.uniqueWorkflowId );
15811584 } catch (o2::framework::RuntimeErrorRef& ref) {
15821585 auto & err = o2::framework::error_from_ref (ref);
1583- LOG (ERROR ) << " Unable to merge configurations: " << err.what ;
1586+ LOGP (ERROR , " unable to merge configurations in {}: {} " , driverInfo. argv [ 0 ], err.what ) ;
15841587#ifdef DPL_ENABLE_BACKTRACE
15851588 std::cerr << " \n Stacktrace follows:\n\n " ;
15861589 backtrace_symbols_fd (err.backtrace , err.maxBacktrace , STDERR_FILENO );
@@ -2211,7 +2214,10 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,
22112214
22122215 if (isatty (STDIN_FILENO ) == false && isInputConfig ()) {
22132216 std::vector<DataProcessorSpec> importedWorkflow;
2214- WorkflowSerializationHelpers::import (std::cin, importedWorkflow, dataProcessorInfos, commandInfo);
2217+ bool previousWorked = WorkflowSerializationHelpers::import (std::cin, importedWorkflow, dataProcessorInfos, commandInfo);
2218+ if (previousWorked == false ) {
2219+ exit (1 );
2220+ }
22152221
22162222 size_t workflowHashB = 0 ;
22172223 for (auto & dp : importedWorkflow) {
@@ -2341,7 +2347,7 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,
23412347 .run (),
23422348 varmap);
23432349 } catch (std::exception const & e) {
2344- std::cerr << " Error: " << e.what () << std::endl ;
2350+ LOGP ( ERROR , " error parsing options of {}: {} " , argv[ 0 ], e.what ()) ;
23452351 exit (1 );
23462352 }
23472353 conflicting_options (varmap, " dds" , " o2-control" );
@@ -2416,8 +2422,8 @@ int doMain(int argc, char** argv, o2::framework::WorkflowSpec const& workflow,
24162422 frameworkId);
24172423}
24182424
2419- void doBoostException (boost::exception& e)
2425+ void doBoostException (boost::exception& e, char const * processName )
24202426{
2421- LOG (ERROR ) << " error while setting up workflow: \n "
2422- << boost::current_exception_diagnostic_information (true );
2427+ LOGP (ERROR , " error while setting up workflow in {}: {} " ,
2428+ processName, boost::current_exception_diagnostic_information (true ) );
24232429}
0 commit comments