From 0474bc99f8f9fd74b0d7f89b367327c32337752d Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <frank.winklmeier@cern.ch> Date: Wed, 15 Nov 2017 14:09:35 +0000 Subject: [PATCH] Remove IssueSeverity support from StatusCode and release --- GaudiExamples/CMakeLists.txt | 1 - GaudiExamples/options/ErrorLog.opts | 53 ---- GaudiExamples/src/ErrorLog/ErrorLogTest.cpp | 54 ----- GaudiExamples/src/ErrorLog/ErrorLogTest.h | 22 -- .../qmtest/gaudiexamples.qms/errorlog.qmt | 21 -- GaudiExamples/tests/qmtest/refs/ErrorLog.ref | 72 ------ .../tests/qmtest/refs/ErrorLog.ref.winxp | 58 ----- .../tests/qmtest/refs/ErrorLog_err.ref | 1 - .../tests/qmtest/refs/ErrorLog_err.ref.winxp | 1 - GaudiGSL/GaudiMath/NumericalDerivative.h | 2 + GaudiKernel/CMakeLists.txt | 2 +- GaudiKernel/GaudiKernel/AlgToolHistory.h | 1 + GaudiKernel/GaudiKernel/DataObject.h | 1 + GaudiKernel/GaudiKernel/IIssueLogger.h | 19 -- GaudiKernel/GaudiKernel/IssueSeverity.h | 113 --------- GaudiKernel/GaudiKernel/StatusCode.h | 49 +--- GaudiKernel/dict/dictionary.h | 1 - GaudiKernel/dict/dictionary.xml | 2 - .../src/Lib/DataHandleHolderVisitor.cpp | 1 + GaudiKernel/src/Lib/IssueSeverity.cpp | 36 --- GaudiKernel/src/Lib/StatusCode.cpp | 7 - GaudiKernel/tests/src/test_IssueSeverity.cpp | 57 ----- GaudiKernel/tests/src/test_StatusCode.cpp | 131 ++++++++++ GaudiMonitor/src/IssueLogger.cpp | 227 ------------------ GaudiMonitor/src/IssueLogger.h | 57 ----- GaudiMonitor/src/StreamLogger.cpp | 18 -- GaudiMonitor/src/StreamLogger.h | 31 --- GaudiSvc/doc/IssueLogger.txt | 110 --------- GaudiUtils/src/component/XMLFileCatalog.h | 2 + 29 files changed, 149 insertions(+), 1001 deletions(-) delete mode 100644 GaudiExamples/options/ErrorLog.opts delete mode 100644 GaudiExamples/src/ErrorLog/ErrorLogTest.cpp delete mode 100644 GaudiExamples/src/ErrorLog/ErrorLogTest.h delete mode 100644 GaudiExamples/tests/qmtest/gaudiexamples.qms/errorlog.qmt delete mode 100644 GaudiExamples/tests/qmtest/refs/ErrorLog.ref delete mode 100644 GaudiExamples/tests/qmtest/refs/ErrorLog.ref.winxp delete mode 100644 GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref delete mode 100644 GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref.winxp delete mode 100644 GaudiKernel/GaudiKernel/IIssueLogger.h delete mode 100644 GaudiKernel/GaudiKernel/IssueSeverity.h delete mode 100644 GaudiKernel/src/Lib/IssueSeverity.cpp delete mode 100644 GaudiKernel/tests/src/test_IssueSeverity.cpp create mode 100644 GaudiKernel/tests/src/test_StatusCode.cpp delete mode 100644 GaudiMonitor/src/IssueLogger.cpp delete mode 100644 GaudiMonitor/src/IssueLogger.h delete mode 100644 GaudiMonitor/src/StreamLogger.cpp delete mode 100644 GaudiMonitor/src/StreamLogger.h delete mode 100644 GaudiSvc/doc/IssueLogger.txt diff --git a/GaudiExamples/CMakeLists.txt b/GaudiExamples/CMakeLists.txt index 7a462f2f8b..13e5da3725 100644 --- a/GaudiExamples/CMakeLists.txt +++ b/GaudiExamples/CMakeLists.txt @@ -47,7 +47,6 @@ set(GaudiExamples_srcs src/ColorMsg/ColorMsgAlg.cpp src/History/History.cpp src/THist/*.cpp - src/ErrorLog/ErrorLogTest.cpp src/Maps/*.cpp src/MultipleLogStreams/*.cpp src/GaudiCommonTests/*.cpp diff --git a/GaudiExamples/options/ErrorLog.opts b/GaudiExamples/options/ErrorLog.opts deleted file mode 100644 index 15a8217792..0000000000 --- a/GaudiExamples/options/ErrorLog.opts +++ /dev/null @@ -1,53 +0,0 @@ -//############################################################## -// Job options file -//============================================================== - -AuditorSvc.Auditors = { "ChronoAuditor" }; -//-------------------------------------------------------------- - - -//-------------------------------------------------------------- -// Private Application Configuration options -//-------------------------------------------------------------- -ApplicationMgr.TopAlg = { "ErrorLogTest" }; - -// Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL ) -MessageSvc.OutputLevel = 3; -MessageSvc.UseColors = true; -THistSvc.OutputLevel = 2; -ApplicationMgr.OutputLevel = 1; -ServiceManager.OutputLevel = 2; -// HistorySvc.Dump= true; -StatusCodeSvc.OutputLevel = 1; - -// ApplicationMgr.CreateSvc = {"StatusCodeSvc", "THistSvc"}; - - - - -//THistSvc.Output = {"new DATAFILE='tuple1.rt' TYP='ROOT' OPT='NEW'"}; - -IssueLogger.OutputLevel = 1; -IssueLogger.ReportLevel = "VERBOSE"; -IssueLogger.TraceBackLevel = "FATAL"; -IssueLogger.ShowTime = true; - -IssueLogger.Output = {"DEBUG='MsgSvc'"}; -IssueLogger.Output += {"WARNING='test.out'"}; -IssueLogger.Output += {"ERROR='STDERR'"}; - - -//-------------------------------------------------------------- -// Event related parameters -//-------------------------------------------------------------- -ApplicationMgr.EvtMax = 20; -ApplicationMgr.EvtSel = "NONE"; - -//-------------------------------------------------------------- -// Other Service Options -//-------------------------------------------------------------- -//ApplicationMgr.HistogramPersistency = "HBOOK"; -//ApplicationMgr.HistogramPersistency = "ROOT"; -//RootHistSvc.OutputFile = "histo.root"; -//HbookHistSvc.OutputFile = "histo.hbook"; - diff --git a/GaudiExamples/src/ErrorLog/ErrorLogTest.cpp b/GaudiExamples/src/ErrorLog/ErrorLogTest.cpp deleted file mode 100644 index b6d8f2eb15..0000000000 --- a/GaudiExamples/src/ErrorLog/ErrorLogTest.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Include files -#include "ErrorLogTest.h" - -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/RndmGenerators.h" - -#include "GaudiKernel/IssueSeverity.h" - -DECLARE_COMPONENT( ErrorLogTest ) - -//------------------------------------------------------------------------------ -ErrorLogTest::ErrorLogTest( const std::string& name, ISvcLocator* pSvcLocator ) : Algorithm( name, pSvcLocator ) -//------------------------------------------------------------------------------ -{ -} - -//------------------------------------------------------------------------------ -StatusCode ErrorLogTest::initialize() -//------------------------------------------------------------------------------ -{ - - // if (service("THistSvc",m_ths).isFailure()) { - // error() << "Couldn't get THistSvc" << endmsg; - // return StatusCode::FAILURE; - // } - - IssueSeverity err0 = ISSUE( IssueSeverity::ERROR, "ERROR level ErrObj" ); - IssueSeverity war = ISSUE( IssueSeverity::WARNING, "this is a warning" ); - IssueSeverity fat = ISSUE( IssueSeverity::FATAL, "this is a fatal" ); - - // StatusCode sc(StatusCode::SUCCESS, ISSUE(IssueSeverity::DEBUG,"debug3 ErrObj")); - - StatusCode sc = STATUSCODE( StatusCode::SUCCESS, IssueSeverity::DEBUG, "debug" ); - - StatusCode sc2( ISSUE( IssueSeverity::INFO, "info ErrObj" ) ); - - return sc2; -} - -//------------------------------------------------------------------------------ -StatusCode ErrorLogTest::execute() -//------------------------------------------------------------------------------ -{ - ISSUE( IssueSeverity::WARNING, "warning level ErrObj in execute" ); - return StatusCode::SUCCESS; -} - -//------------------------------------------------------------------------------ -StatusCode ErrorLogTest::finalize() -//------------------------------------------------------------------------------ -{ - warning() << "Finalizing..." << endmsg; - return StatusCode::SUCCESS; -} diff --git a/GaudiExamples/src/ErrorLog/ErrorLogTest.h b/GaudiExamples/src/ErrorLog/ErrorLogTest.h deleted file mode 100644 index e986eb22b2..0000000000 --- a/GaudiExamples/src/ErrorLog/ErrorLogTest.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GAUDIEXAMPLE_ERRORLOGTEST_H -#define GAUDIEXAMPLE_ERRORLOGTEST_H 1 - -// Include files -#include "GaudiKernel/Algorithm.h" - -class ErrorLogTest : public Algorithm -{ - -public: - // Constructor of this form must be provided - ErrorLogTest( const std::string& name, ISvcLocator* pSvcLocator ); - - // Three mandatory member functions of any algorithm - StatusCode initialize() override; - StatusCode execute() override; - StatusCode finalize() override; - -private: -}; - -#endif // diff --git a/GaudiExamples/tests/qmtest/gaudiexamples.qms/errorlog.qmt b/GaudiExamples/tests/qmtest/gaudiexamples.qms/errorlog.qmt deleted file mode 100644 index 6b13992c04..0000000000 --- a/GaudiExamples/tests/qmtest/gaudiexamples.qms/errorlog.qmt +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'> -<extension class="GaudiTest.GaudiExeTest" kind="test"> -<argument name="args"><set><text>$GAUDIEXAMPLESROOT/options/ErrorLog.opts</text></set></argument> - <argument name="use_temp_dir"><enumeral>true</enumeral></argument> - <argument name="reference"><text>refs/ErrorLog.ref</text></argument> - <argument name="error_reference"><text>refs/ErrorLog_err.ref</text></argument> -<argument name="validator"><text> -# Normalize the filename in the output of the test -preproc = (normalizeExamples + - LineSkipper(["0 local"], - regexps=[r"0x[0-9a-fA-F#]+ *(Algorithm::sysI|ErrorLogTest::i)nitialize\(\) *\[", - r"0x[0-9a-fA-F#]+ *void std::(call_once|__once_call_impl)<", - r"0x[0-9a-fA-F#]* *(__gxx_personality_v0|pthread_once|_start|main) *\["]) + - RegexpReplacer(r"(?<=\s)\S+ErrorLogTest\.cpp:", "ErrorLogTest.cpp:", "ErrorLogTest.cpp:") + - RegexpReplacer(r"\[.*/([^/]*.*)\]", r"[\1]", r"^#[0-9]+ +0x########") + # normalize paths to libraries - RegexpReplacer(r"^#[0-9]+ +", r"#N ", "^#[0-9]+ +0x########") # normalize stack levels count - ) - -validateWithReference(preproc = preproc) -</text></argument> -</extension> diff --git a/GaudiExamples/tests/qmtest/refs/ErrorLog.ref b/GaudiExamples/tests/qmtest/refs/ErrorLog.ref deleted file mode 100644 index edd28e8680..0000000000 --- a/GaudiExamples/tests/qmtest/refs/ErrorLog.ref +++ /dev/null @@ -1,72 +0,0 @@ -JobOptionsSvc INFO # =======> Gaudi/GaudiExamples/options/ErrorLog.opts -JobOptionsSvc INFO # (5,1): AuditorSvc.Auditors = ["ChronoAuditor"] -JobOptionsSvc INFO # (12,1): ApplicationMgr.TopAlg = ["ErrorLogTest"] -JobOptionsSvc INFO # (15,1): MessageSvc.OutputLevel = 3 -JobOptionsSvc INFO # (16,1): MessageSvc.UseColors = 1 -JobOptionsSvc INFO # (17,1): THistSvc.OutputLevel = 2 -JobOptionsSvc INFO # (18,1): ApplicationMgr.OutputLevel = 1 -JobOptionsSvc INFO # (19,1): ServiceManager.OutputLevel = 2 -JobOptionsSvc INFO # (21,1): StatusCodeSvc.OutputLevel = 1 -JobOptionsSvc INFO # (30,1): IssueLogger.OutputLevel = 1 -JobOptionsSvc INFO # (31,1): IssueLogger.ReportLevel = "VERBOSE" -JobOptionsSvc INFO # (32,1): IssueLogger.TraceBackLevel = "FATAL" -JobOptionsSvc INFO # (33,1): IssueLogger.ShowTime = 1 -JobOptionsSvc INFO # (35,1): IssueLogger.Output = ["DEBUG='MsgSvc'"] -JobOptionsSvc INFO # (36,1): IssueLogger.Output += ["WARNING='test.out'"] -JobOptionsSvc INFO # (37,1): IssueLogger.Output += ["ERROR='STDERR'"] -JobOptionsSvc INFO # (43,1): ApplicationMgr.EvtMax = 20 -JobOptionsSvc INFO # (44,1): ApplicationMgr.EvtSel = "NONE" -JobOptionsSvc INFO Job options successfully read in from Gaudi/GaudiExamples/options/ErrorLog.opts -ApplicationMgr SUCCESS -==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v28r1) - running on pclhcb117 on Mon Dec 19 17:34:53 2016 -====================================================================================================================================[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service EvtDataSvc/EventDataSvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service DetDataSvc/DetectorDataSvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service HistogramSvc/HistogramDataSvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service HbookCnv::PersSvc/HbookHistSvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service RootHistCnv::PersSvc/RootHistSvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service EvtPersistencySvc/EventPersistencySvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service DetPersistencySvc/DetectorPersistencySvc[m -ApplicationMgr VERBOSE declareMultiSvcType: declared service HistogramPersistencySvc/HistogramPersistencySvc[m -ApplicationMgr DEBUG Loading declared DLL's[m -ApplicationMgr VERBOSE addMultiSvc: added service EventLoopMgr/EventLoopMgr[m -ApplicationMgr INFO Application Manager Configured successfully[m -IssueLogger DEBUG Property update for OutputLevel : new value = 1[m -IssueLogger DEBUG Service base class initialized successfully[m -IssueLogger DEBUG Writing VERBOSE issues to MsgStream[m -IssueLogger DEBUG Writing DEBUG1 issues to MsgStream[m -IssueLogger DEBUG Writing DEBUG2 issues to MsgStream[m -IssueLogger DEBUG Writing DEBUG3 issues to MsgStream[m -IssueLogger DEBUG Writing INFO issues to MsgStream[m -IssueLogger DEBUG Writing RECOVERABLE issues to MsgStream[m -IssueLogger DEBUG Writing FATAL issues to MsgStream[m -IssueLogger DEBUG Writing ALWAYS issues to MsgStream[m -[94;101;1mIssueLogger FATAL FATAL ErrorLogTest.cpp:29 "this is a fatal" [17:34:53 2016/12/19 CET] -#1 0x7fa2c8cb6260 MinimalEventLoopMgr::initialize() [libGaudiKernel.so] -#2 0x7fa2c4695980 EventLoopMgr::initialize() [libGaudiCoreSvc.so] -#3 0x7fa2c8c32500 Service::sysInitialize_imp() [libGaudiKernel.so] -#4 0 local [/lib/x86_64-linux-gnu/libpthread.so.0] -#5 0x7fa2c8c2f910 Service::sysInitialize() [libGaudiKernel.so] -#6 0x7fa2c469e100 ServiceManager::initialize() [libGaudiCoreSvc.so] -#7 0x7fa2c465f290 ApplicationMgr::initialize() [libGaudiCoreSvc.so] -#8 0x7fa2c465b790 ApplicationMgr::GoToState(Gaudi::StateMachine::State, bool) [libGaudiCoreSvc.so] -#9 0x7fa2c465b790 ApplicationMgr::GoToState(Gaudi::StateMachine::State, bool) [libGaudiCoreSvc.so] -#10 0x7fa2c465c970 ApplicationMgr::run() [libGaudiCoreSvc.so] -#11 0x7fa2c8b5e8f0 GaudiMain [libGaudiKernel.so] -#12 0x7fa2c8524740 __libc_start_main [libc.so.6] -#13 0x400800 _start [Gaudi.exe] -[m -IssueLogger INFO INFO ErrorLogTest.cpp:35 "info ErrObj" [17:34:53 2016/12/19 CET][m -[93;1mEventLoopMgr WARNING Unable to locate service "EventSelector" [m -[93;1mEventLoopMgr WARNING No events will be processed from external input.[m -[93;1mHistogramPersis...WARNING Histograms saving not required.[m -ApplicationMgr INFO Application Manager Initialized successfully[m -ApplicationMgr INFO Application Manager Started successfully[m -ApplicationMgr INFO Application Manager Stopped successfully[m -[93;1mErrorLogTest WARNING Finalizing...[m -EventLoopMgr INFO Histograms converted successfully according to request.[m -IssueLogger DEBUG IssueLogger::finalize[m -ApplicationMgr INFO Application Manager Finalized successfully[m -ApplicationMgr INFO Application Manager Terminated successfully[m diff --git a/GaudiExamples/tests/qmtest/refs/ErrorLog.ref.winxp b/GaudiExamples/tests/qmtest/refs/ErrorLog.ref.winxp deleted file mode 100644 index 151e70e0ab..0000000000 --- a/GaudiExamples/tests/qmtest/refs/ErrorLog.ref.winxp +++ /dev/null @@ -1,58 +0,0 @@ -JobOptionsSvc INFO # =======> D:/Profiles/clemenci/cmtuser/Gaudi/GaudiExamples/options/ErrorLog.opts) -JobOptionsSvc INFO # (5,1): AuditorSvc.Auditors = ["ChronoAuditor"] -JobOptionsSvc INFO # (12,1): ApplicationMgr.TopAlg = ["ErrorLogTest"] -JobOptionsSvc INFO # (15,1): MessageSvc.OutputLevel = 3 -JobOptionsSvc INFO # (16,1): MessageSvc.UseColors = 1 -JobOptionsSvc INFO # (17,1): THistSvc.OutputLevel = 2 -JobOptionsSvc INFO # (18,1): ApplicationMgr.OutputLevel = 1 -JobOptionsSvc INFO # (19,1): ServiceManager.OutputLevel = 2 -JobOptionsSvc INFO # (21,1): StatusCodeSvc.OutputLevel = 1 -JobOptionsSvc INFO # (30,1): IssueLogger.OutputLevel = 1 -JobOptionsSvc INFO # (31,1): IssueLogger.ReportLevel = "VERBOSE" -JobOptionsSvc INFO # (32,1): IssueLogger.TraceBackLevel = "FATAL" -JobOptionsSvc INFO # (33,1): IssueLogger.ShowTime = 1 -JobOptionsSvc INFO # (35,1): IssueLogger.Output = ["DEBUG='MsgSvc'"] -JobOptionsSvc INFO # (36,1): IssueLogger.Output += ["WARNING='test.out'"] -JobOptionsSvc INFO # (37,1): IssueLogger.Output += ["ERROR='STDERR'"] -JobOptionsSvc INFO # (43,1): ApplicationMgr.EvtMax = 20 -JobOptionsSvc INFO # (44,1): ApplicationMgr.EvtSel = "NONE" -JobOptionsSvc INFO Job options successfully read in from D:\Profiles\clemenci\cmtuser\Gaudi\GaudiExamples\options\ErrorLog.opts -ApplicationMgr SUCCESS -==================================================================================================================================== - Welcome to ApplicationMgr $Revision: 1.77 $ - running on CERNTSLHCB05 on 08/16/11 13:57:26 -==================================================================================================================================== -ApplicationMgr VERBOSE declareMultiSvcType: declared service EvtDataSvc/EventDataSvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service DetDataSvc/DetectorDataSvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service HistogramSvc/HistogramDataSvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service HbookCnv::PersSvc/HbookHistSvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service RootHistCnv::PersSvc/RootHistSvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service EvtPersistencySvc/EventPersistencySvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service DetPersistencySvc/DetectorPersistencySvc -ApplicationMgr VERBOSE declareMultiSvcType: declared service HistogramPersistencySvc/HistogramPersistencySvc -ApplicationMgr DEBUG Loading declared DLL's -ApplicationMgr VERBOSE addMultiSvc: added service EventLoopMgr/EventLoopMgr -ApplicationMgr INFO Application Manager Configured successfully -IssueLogger DEBUG Service base class initialized successfully -IssueLogger DEBUG Writing VERBOSE issues to MsgStream -IssueLogger DEBUG Writing DEBUG1 issues to MsgStream -IssueLogger DEBUG Writing DEBUG2 issues to MsgStream -IssueLogger DEBUG Writing DEBUG3 issues to MsgStream -IssueLogger DEBUG Writing INFO issues to MsgStream -IssueLogger DEBUG Writing RECOVERABLE issues to MsgStream -IssueLogger DEBUG Writing FATAL issues to MsgStream -IssueLogger DEBUG Writing ALWAYS issues to MsgStream -IssueLogger FATAL FATAL ..\src\ErrorLog\ErrorLogTest.cpp:38 "this is a fatal" [13:57:26 2011/08/16 W. Europe Daylight Time] - -IssueLogger INFO INFO ..\src\ErrorLog\ErrorLogTest.cpp:44 "info ErrObj" [13:57:26 2011/08/16 W. Europe Daylight Time] -EventLoopMgr WARNING Unable to locate service "EventSelector" -EventLoopMgr WARNING No events will be processed from external input. -HistogramPersis...WARNING Histograms saving not required. -ApplicationMgr INFO Application Manager Initialized successfully -ApplicationMgr INFO Application Manager Started successfully -ApplicationMgr INFO Application Manager Stopped successfully -ErrorLogTest WARNING Finalizing... -EventLoopMgr INFO Histograms converted successfully according to request. -IssueLogger DEBUG IssueLogger::finalize -ApplicationMgr INFO Application Manager Finalized successfully -ApplicationMgr INFO Application Manager Terminated successfully diff --git a/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref b/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref deleted file mode 100644 index 454e5f4def..0000000000 --- a/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref +++ /dev/null @@ -1 +0,0 @@ -ERROR ../src/ErrorLog/ErrorLogTest.cpp:27 "ERROR level ErrObj" [00:00:00 1970-01-01 CEST] diff --git a/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref.winxp b/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref.winxp deleted file mode 100644 index 553670e0a4..0000000000 --- a/GaudiExamples/tests/qmtest/refs/ErrorLog_err.ref.winxp +++ /dev/null @@ -1 +0,0 @@ -ERROR ..\src\ErrorLog\ErrorLogTest.cpp:36 "ERROR level ErrObj" [14:38:30 2011/08/16 W. Europe Daylight Time] diff --git a/GaudiGSL/GaudiMath/NumericalDerivative.h b/GaudiGSL/GaudiMath/NumericalDerivative.h index fffa2ad069..53ea05cc21 100644 --- a/GaudiGSL/GaudiMath/NumericalDerivative.h +++ b/GaudiGSL/GaudiMath/NumericalDerivative.h @@ -12,6 +12,8 @@ #include "CLHEP/GenericFunctions/AbsFunction.hh" // ============================================================================ +#include <memory> + #if defined( __clang__ ) || defined( __CLING__ ) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winconsistent-missing-override" diff --git a/GaudiKernel/CMakeLists.txt b/GaudiKernel/CMakeLists.txt index 01826cd661..4e523d40d1 100644 --- a/GaudiKernel/CMakeLists.txt +++ b/GaudiKernel/CMakeLists.txt @@ -145,7 +145,7 @@ gaudi_add_unit_test(test_PropertyHolder tests/src/test_PropertyHolder.cpp gaudi_add_unit_test(test_Property tests/src/test_Property.cpp LINK_LIBRARIES GaudiKernel TYPE Boost) -gaudi_add_unit_test(test_IssueSeverity tests/src/test_IssueSeverity.cpp +gaudi_add_unit_test(test_StatusCode tests/src/test_StatusCode.cpp LINK_LIBRARIES GaudiKernel TYPE Boost) gaudi_add_unit_test(test_SystemTypeinfoName tests/src/test_SystemTypeinfoName.cpp diff --git a/GaudiKernel/GaudiKernel/AlgToolHistory.h b/GaudiKernel/GaudiKernel/AlgToolHistory.h index 64622ff3f5..a36a627542 100644 --- a/GaudiKernel/GaudiKernel/AlgToolHistory.h +++ b/GaudiKernel/GaudiKernel/AlgToolHistory.h @@ -7,6 +7,7 @@ class AlgTool; class JobHistory; +#include <memory> #include <string> #include <vector> diff --git a/GaudiKernel/GaudiKernel/DataObject.h b/GaudiKernel/GaudiKernel/DataObject.h index fef340b2c8..762a2fd014 100644 --- a/GaudiKernel/GaudiKernel/DataObject.h +++ b/GaudiKernel/GaudiKernel/DataObject.h @@ -6,6 +6,7 @@ #include "GaudiKernel/StatusCode.h" // STL includes +#include <memory> #include <ostream> #include <string> diff --git a/GaudiKernel/GaudiKernel/IIssueLogger.h b/GaudiKernel/GaudiKernel/IIssueLogger.h deleted file mode 100644 index ec0875eb31..0000000000 --- a/GaudiKernel/GaudiKernel/IIssueLogger.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef GAUDIKERNEL_IISSUELOGGER_H -#define GAUDIKERNEL_IISSUELOGGER_H - -#include "GaudiKernel/IService.h" -#include "GaudiKernel/IssueSeverity.h" -#include <string> - -class GAUDI_API IIssueLogger : virtual public IService -{ - -public: - /// InterfaceID - DeclareInterfaceID( IIssueLogger, 2, 0 ); - - virtual void report( IssueSeverity::Level level, const std::string& msg, const std::string& origin ) = 0; - virtual void report( const IssueSeverity& err ) = 0; -}; - -#endif diff --git a/GaudiKernel/GaudiKernel/IssueSeverity.h b/GaudiKernel/GaudiKernel/IssueSeverity.h deleted file mode 100644 index e6529a1ea6..0000000000 --- a/GaudiKernel/GaudiKernel/IssueSeverity.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef GAUDIKERNEL_ISSUESEVERITY_H -#define GAUDIKERNEL_ISSUESEVERITY_H 1 - -class StatusCode; - -#include <iostream> -#include <map> -#include <string> - -#include "GaudiKernel/Kernel.h" - -#define ISSUE( x, y ) IssueSeverity( x, __LINE__, __FILE__, y ) -#define STATUSCODE( z, x, y ) StatusCode( z, ISSUE( x, y ) ) - -class IIssueLogger; - -#ifdef _WIN32 -#ifdef ERROR -#undef ERROR -#endif -#endif - -class GAUDI_API IssueSeverity final -{ - -public: - enum Level { - NIL = 0, - VERBOSE, - DEBUG, - DEBUG1, - DEBUG2, - DEBUG3, - INFO, - WARNING, - RECOVERABLE, - ERROR, - FATAL, - ALWAYS, - NUM_LEVELS - }; - - IssueSeverity() {} - IssueSeverity( IssueSeverity::Level level, int line, std::string file, std::string msg = "" ); - IssueSeverity( IssueSeverity::Level level, std::string msg = "" ); - - IssueSeverity( const IssueSeverity& ) = delete; - IssueSeverity& operator=( const IssueSeverity& ) = delete; - IssueSeverity( IssueSeverity&& ) noexcept; - IssueSeverity& operator=( IssueSeverity&& ) noexcept; - - ~IssueSeverity(); - - void setLevel( const IssueSeverity::Level& l ) { m_level = l; } - void setMsg( std::string m ) { m_msg = std::move( m ); } - - IssueSeverity::Level getLevel() const { return m_level; } - std::string getMsg() const { return m_msg; } - std::string getOrigin() const; - - void report(); - - friend inline std::ostream& operator<<( std::ostream&, const IssueSeverity& ); - -private: - std::string m_file; - std::string m_msg; - - int m_line = 0; - IssueSeverity::Level m_level = IssueSeverity::NIL; - bool m_reported = true; - - static bool m_init; - static IIssueLogger* m_ers; -}; - -inline IssueSeverity::IssueSeverity( IssueSeverity::Level level, int line, std::string file, std::string msg ) - : m_file( std::move( file ) ), m_msg( std::move( msg ) ), m_line( line ), m_level( level ), m_reported( false ) -{ - report(); -} - -inline IssueSeverity::IssueSeverity( IssueSeverity::Level level, std::string msg ) - : IssueSeverity( std::move( level ), 0, "??", std::move( msg ) ) -{ -} - -inline IssueSeverity::IssueSeverity( IssueSeverity&& rhs ) noexcept -{ - m_file = std::move( rhs.m_file ); - m_msg = std::move( rhs.m_msg ); - m_line = rhs.m_line; - m_level = rhs.m_level; - m_reported = std::exchange( rhs.m_reported, true ); -} - -inline IssueSeverity& IssueSeverity::operator=( IssueSeverity&& rhs ) noexcept -{ - m_file = std::move( rhs.m_file ); - m_msg = std::move( rhs.m_msg ); - m_line = rhs.m_line; - m_level = rhs.m_level; - m_reported = std::exchange( rhs.m_reported, true ); - return *this; -} - -std::ostream& operator<<( std::ostream& os, const IssueSeverity& rhs ) -{ - os << "ISSUE: level " << rhs.getLevel() << " from: " << rhs.getOrigin() << " msg: " << rhs.getMsg(); - return os; -} - -#endif diff --git a/GaudiKernel/GaudiKernel/StatusCode.h b/GaudiKernel/GaudiKernel/StatusCode.h index 4a67d50646..b908e71760 100644 --- a/GaudiKernel/GaudiKernel/StatusCode.h +++ b/GaudiKernel/GaudiKernel/StatusCode.h @@ -2,12 +2,10 @@ #define GAUDIKERNEL_STATUSCODE_H #include <ostream> +#include <utility> -#include "GaudiKernel/IssueSeverity.h" #include "GaudiKernel/Kernel.h" -#include <memory> - /** * @class StatusCode StatusCode.h GaudiKernel/StatusCode.h * @@ -33,35 +31,12 @@ public: /// Constructor. StatusCode() = default; - StatusCode( unsigned long code, IssueSeverity&& sev ) : d_code( code ) - { - try { // ensure that we do not throw even if we cannot move the severity - m_severity = std::make_shared<const IssueSeverity>( std::move( sev ) ); - } catch ( ... ) { - } - } - - StatusCode( IssueSeverity&& is ) - : StatusCode( is.getLevel() == IssueSeverity::RECOVERABLE - ? StatusCode::RECOVERABLE - : ( is.getLevel() < IssueSeverity::ERROR ? StatusCode::SUCCESS : StatusCode::FAILURE ), - std::move( is ) ) - { - } - StatusCode( unsigned long code, bool checked = false ) : d_code( code ), m_checked( checked ) {} - StatusCode( const StatusCode& rhs ) : d_code( rhs.d_code ), m_checked( rhs.m_checked ), m_severity( rhs.m_severity ) - { - rhs.m_checked = true; - } + StatusCode( const StatusCode& rhs ) : d_code( rhs.d_code ), m_checked( rhs.m_checked ) { rhs.m_checked = true; } /// Move constructor. - StatusCode( StatusCode&& rhs ) noexcept - : d_code( rhs.d_code ), m_checked( rhs.m_checked ), m_severity( std::move( rhs.m_severity ) ) - { - rhs.m_checked = true; - } + StatusCode( StatusCode&& rhs ) noexcept : d_code( rhs.d_code ), m_checked( rhs.m_checked ) { rhs.m_checked = true; } /// Destructor. ~StatusCode() @@ -108,12 +83,12 @@ public: void setChecked() const { m_checked = true; } void ignore() const { setChecked(); } + /// Has the StatusCode been checked? + bool checked() const { return m_checked; } + /// Cast operator. operator unsigned long() const { return getCode(); } - /// Severity - GAUDI_API const IssueSeverity& severity() const; - /// Assignment operator. StatusCode& operator=( unsigned long value ) { @@ -122,11 +97,8 @@ public: } StatusCode& operator=( const StatusCode& rhs ) { - if ( this == &rhs ) return *this; // Protection against self-assignment - d_code = rhs.d_code; - m_checked = rhs.m_checked; - rhs.m_checked = true; - m_severity = rhs.m_severity; + d_code = rhs.d_code; + m_checked = std::exchange( rhs.m_checked, true ); return *this; } @@ -179,9 +151,8 @@ public: protected: /// The status code. - unsigned long d_code = SUCCESS; ///< The status code - mutable bool m_checked = false; ///< If the Status code has been checked - std::shared_ptr<const IssueSeverity> m_severity; ///< Pointer to a IssueSeverity + unsigned long d_code = SUCCESS; ///< The status code + mutable bool m_checked = false; ///< If the Status code has been checked static bool s_checking; ///< Global flag to control if StatusCode need to be checked diff --git a/GaudiKernel/dict/dictionary.h b/GaudiKernel/dict/dictionary.h index 2bd3a4fc3e..fe1d54ec60 100644 --- a/GaudiKernel/dict/dictionary.h +++ b/GaudiKernel/dict/dictionary.h @@ -64,7 +64,6 @@ #include "GaudiKernel/IInspectable.h" #include "GaudiKernel/IInspector.h" #include "GaudiKernel/IInterface.h" -#include "GaudiKernel/IIssueLogger.h" #include "GaudiKernel/IJobOptionsSvc.h" #include "GaudiKernel/IMagneticFieldSvc.h" #include "GaudiKernel/IMessageSvc.h" diff --git a/GaudiKernel/dict/dictionary.xml b/GaudiKernel/dict/dictionary.xml index 08cfb0f6c0..35fbd69fdf 100644 --- a/GaudiKernel/dict/dictionary.xml +++ b/GaudiKernel/dict/dictionary.xml @@ -4,7 +4,6 @@ <class pattern="DataObjectHandle*"/> <!-- Base classes in GaudiKernel --> - <class name="IssueSeverity"/> <class name="StatusCode"/> <class name="Gaudi::Details::PropertyBase"> <field name="m_typeinfo" transient="true"/> @@ -72,7 +71,6 @@ <class name="IInspector"/> <class name="IInterface"/> <class name="InterfaceID"/> - <class name="IIssueLogger"/> <class name="IJobOptionsSvc"/> <class name="IMagneticFieldSvc"/> <class name="IMessageSvc"/> diff --git a/GaudiKernel/src/Lib/DataHandleHolderVisitor.cpp b/GaudiKernel/src/Lib/DataHandleHolderVisitor.cpp index 2c8b7675e4..c4a6112fa1 100644 --- a/GaudiKernel/src/Lib/DataHandleHolderVisitor.cpp +++ b/GaudiKernel/src/Lib/DataHandleHolderVisitor.cpp @@ -2,6 +2,7 @@ #include "GaudiKernel/DataHandle.h" #include "GaudiKernel/DataObjID.h" #include "GaudiKernel/IDataHandleHolder.h" +#include <functional> #include <tuple> #include <typeinfo> diff --git a/GaudiKernel/src/Lib/IssueSeverity.cpp b/GaudiKernel/src/Lib/IssueSeverity.cpp deleted file mode 100644 index 34d3d0896d..0000000000 --- a/GaudiKernel/src/Lib/IssueSeverity.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#define GAUDIKERNEL_ISSUESEVERITY_CPP 1 - -#include "GaudiKernel/IssueSeverity.h" -#include "GaudiKernel/Bootstrap.h" -#include "GaudiKernel/IIssueLogger.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/StatusCode.h" -#include "GaudiKernel/System.h" - -#include <sstream> - -bool IssueSeverity::m_init( false ); -IIssueLogger* IssueSeverity::m_ers( nullptr ); - -IssueSeverity::~IssueSeverity() -{ - if ( !m_reported ) { - report(); - } -} - -void IssueSeverity::report() -{ - if ( !m_init ) { - m_init = true; - m_ers = Gaudi::svcLocator()->service<IIssueLogger>( "IssueLogger" ).get(); - } - if ( m_ers ) { - m_ers->report( *this ); - } else { - std::cerr << *this << std::endl; - } - m_reported = true; -} - -std::string IssueSeverity::getOrigin() const { return m_file + ":" + std::to_string( m_line ); } diff --git a/GaudiKernel/src/Lib/StatusCode.cpp b/GaudiKernel/src/Lib/StatusCode.cpp index 073e2997cd..6017bd4221 100644 --- a/GaudiKernel/src/Lib/StatusCode.cpp +++ b/GaudiKernel/src/Lib/StatusCode.cpp @@ -5,7 +5,6 @@ #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/IStatusCodeSvc.h" #include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/IssueSeverity.h" #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/System.h" #include <exception> @@ -22,12 +21,6 @@ void StatusCode::disableChecking() { s_checking = false; } bool StatusCode::checkingEnabled() { return s_checking; } -const IssueSeverity& StatusCode::severity() const -{ - static const IssueSeverity dummy; - return m_severity ? *m_severity : dummy; -} - void StatusCode::check() { diff --git a/GaudiKernel/tests/src/test_IssueSeverity.cpp b/GaudiKernel/tests/src/test_IssueSeverity.cpp deleted file mode 100644 index f6e3494aa2..0000000000 --- a/GaudiKernel/tests/src/test_IssueSeverity.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE test_IssueSeverity -#include <boost/test/unit_test.hpp> - -#include <iostream> -#include <string> - -#include "GaudiKernel/IssueSeverity.h" - -// Use function return value to generate rvalue references -IssueSeverity returnIssue() -{ - return IssueSeverity{IssueSeverity::Level::INFO, 666, "ghost.cpp", "issue severity test"}; -} - -BOOST_AUTO_TEST_CASE( constructor ) -{ - { - std::cout << "constructor full" << std::endl; - IssueSeverity is{IssueSeverity::Level::INFO, 666, "ghost.cpp", "issue severity test"}; - BOOST_CHECK( is.getLevel() == IssueSeverity::Level::INFO ); - BOOST_CHECK( is.getOrigin() == std::string( "ghost.cpp:666" ) ); - BOOST_CHECK( is.getMsg() == "issue severity test" ); - } - { - std::cout << "constructor partial" << std::endl; - IssueSeverity is{IssueSeverity::Level::INFO, "issue severity test"}; - BOOST_CHECK( is.getLevel() == IssueSeverity::Level::INFO ); - BOOST_CHECK( is.getMsg() == "issue severity test" ); - } - { - std::cout << "constructor move assign" << std::endl; - IssueSeverity is = returnIssue(); - BOOST_CHECK( is.getLevel() == IssueSeverity::Level::INFO ); - BOOST_CHECK( is.getOrigin() == std::string( "ghost.cpp:666" ) ); - BOOST_CHECK( is.getMsg() == "issue severity test" ); - } - { - std::cout << "constructor from rval ref" << std::endl; - IssueSeverity is( returnIssue() ); - BOOST_CHECK( is.getLevel() == IssueSeverity::Level::INFO ); - BOOST_CHECK( is.getOrigin() == std::string( "ghost.cpp:666" ) ); - BOOST_CHECK( is.getMsg() == "issue severity test" ); - } -} - -BOOST_AUTO_TEST_CASE( setter ) -{ - { - std::cout << "setters" << std::endl; - IssueSeverity is{IssueSeverity::Level::INFO, 666, "ghost.cpp", "issue severity test"}; - is.setLevel( IssueSeverity::Level::ERROR ); - BOOST_CHECK( is.getLevel() == IssueSeverity::Level::ERROR ); - is.setMsg( "updated message" ); - BOOST_CHECK( is.getMsg() == "updated message" ); - } -} diff --git a/GaudiKernel/tests/src/test_StatusCode.cpp b/GaudiKernel/tests/src/test_StatusCode.cpp new file mode 100644 index 0000000000..a50d5c7fba --- /dev/null +++ b/GaudiKernel/tests/src/test_StatusCode.cpp @@ -0,0 +1,131 @@ +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE test_StatusCode +#include <boost/test/unit_test.hpp> + +#include "GaudiKernel/StatusCode.h" + +BOOST_AUTO_TEST_CASE( values ) +{ + // default should be SUCCESS + { + StatusCode sc; + BOOST_CHECK( sc == StatusCode::SUCCESS ); + } + + // SUCCESS + { + StatusCode sc( StatusCode::SUCCESS ); + BOOST_CHECK( sc == StatusCode::SUCCESS ); + BOOST_CHECK( sc.getCode() == StatusCode::SUCCESS ); + BOOST_CHECK( sc.isSuccess() == true ); + BOOST_CHECK( sc.isFailure() == false ); + BOOST_CHECK( sc.isRecoverable() == false ); + BOOST_CHECK( static_cast<bool>( sc ) == true ); + } + + // FAILURE + { + StatusCode sc( StatusCode::FAILURE ); + BOOST_CHECK( sc == StatusCode::FAILURE ); + BOOST_CHECK( sc.getCode() == StatusCode::FAILURE ); + BOOST_CHECK( sc.isSuccess() == false ); + BOOST_CHECK( sc.isFailure() == true ); + BOOST_CHECK( sc.isRecoverable() == false ); + BOOST_CHECK( static_cast<bool>( sc ) == false ); + } + + // RECOVERABLE + { + StatusCode sc( StatusCode::RECOVERABLE ); + BOOST_CHECK( sc == StatusCode::RECOVERABLE ); + BOOST_CHECK( sc.getCode() == StatusCode::RECOVERABLE ); + BOOST_CHECK( sc.isSuccess() == false ); + BOOST_CHECK( sc.isFailure() == true ); // !!! note, this particularity + BOOST_CHECK( sc.isRecoverable() == true ); + BOOST_CHECK( static_cast<bool>( sc ) == true ); // !!! + } +} + +BOOST_AUTO_TEST_CASE( user_values ) +{ + enum Status { ERR1 = 10, ERR2 = 12 }; + + { + StatusCode sc( Status::ERR1 ); + BOOST_CHECK( sc.isSuccess() == false ); + BOOST_CHECK( sc.isFailure() == true ); + BOOST_CHECK( sc.isRecoverable() == false ); + BOOST_CHECK( static_cast<bool>( sc ) == true ); // !!! + + sc = Status::ERR2; + BOOST_CHECK( sc == Status::ERR2 ); + } +} + +BOOST_AUTO_TEST_CASE( comparison ) +{ + // Copy and comparison + { + StatusCode sc; + StatusCode sc2( sc ); + BOOST_CHECK( sc == sc2 ); + + sc2.setCode( StatusCode::FAILURE ); + BOOST_CHECK( sc > sc2 ); + BOOST_CHECK( sc2 < sc ); + } +} + +BOOST_AUTO_TEST_CASE( checking ) +{ + { + StatusCode sc( StatusCode::SUCCESS ); + BOOST_CHECK( sc.checked() == false ); + sc.isSuccess(); + BOOST_CHECK( sc.checked() == true ); + } + { + StatusCode sc( StatusCode::SUCCESS ); + sc.ignore(); + BOOST_CHECK( sc.checked() == true ); + } + // Comparison invokes implicit cast --> checked + { + StatusCode sc( StatusCode::SUCCESS ); + if ( sc == StatusCode::SUCCESS ) + ; + BOOST_CHECK( sc.checked() == true ); + } + // Using the comparison operator does not check + // This is probably unintentional and we may want to change this + { + StatusCode sc1( StatusCode::SUCCESS ); + StatusCode sc2( StatusCode::FAILURE ); + BOOST_CHECK( sc1 > sc2 ); + BOOST_CHECK( sc1.checked() == false ); // !!! + BOOST_CHECK( sc2.checked() == false ); // !!! + } + // Cast to long --> checked + { + StatusCode sc; + BOOST_CHECK( sc.checked() == false ); + if ( sc ) + ; + BOOST_CHECK( sc.checked() == true ); + } + // Copy constructor checks source + { + StatusCode sc1( StatusCode::SUCCESS ); + StatusCode sc2( sc1 ); + BOOST_CHECK( sc1.checked() == true ); + BOOST_CHECK( sc2.checked() == false ); + } + // Assignment operator checks rhs + { + StatusCode sc1( StatusCode::SUCCESS ); + StatusCode sc2; + sc2 = sc1; + BOOST_CHECK( sc1.checked() == true ); + BOOST_CHECK( sc2.checked() == false ); + } +} diff --git a/GaudiMonitor/src/IssueLogger.cpp b/GaudiMonitor/src/IssueLogger.cpp deleted file mode 100644 index aeed7b9071..0000000000 --- a/GaudiMonitor/src/IssueLogger.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include "IssueLogger.h" - -#include "GaudiKernel/AttribStringParser.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/System.h" -#include "GaudiKernel/Time.h" - -#include <algorithm> -namespace -{ - - std::string getTraceBack() - { - std::string stack; - constexpr int depth = 30; - constexpr int offset = 5; - System::backTrace( stack, depth, offset ); - return stack; - } - - static const std::map<IssueSeverity::Level, MSG::Level> s_sevMsgMap = { - {IssueSeverity::NIL, MSG::NIL}, {IssueSeverity::VERBOSE, MSG::VERBOSE}, - {IssueSeverity::DEBUG, MSG::DEBUG}, {IssueSeverity::DEBUG1, MSG::DEBUG}, - {IssueSeverity::DEBUG2, MSG::DEBUG}, {IssueSeverity::DEBUG3, MSG::DEBUG}, - {IssueSeverity::INFO, MSG::INFO}, {IssueSeverity::WARNING, MSG::WARNING}, - {IssueSeverity::RECOVERABLE, MSG::ERROR}, {IssueSeverity::ERROR, MSG::ERROR}, - {IssueSeverity::FATAL, MSG::FATAL}, {IssueSeverity::ALWAYS, MSG::ALWAYS}}; - - static const std::map<IssueSeverity::Level, std::string> s_levelTrans = { - {IssueSeverity::VERBOSE, "VERBOSE"}, {IssueSeverity::DEBUG, "DEBUG"}, - {IssueSeverity::DEBUG1, "DEBUG1"}, {IssueSeverity::DEBUG2, "DEBUG2"}, - {IssueSeverity::DEBUG3, "DEBUG3"}, {IssueSeverity::INFO, "INFO"}, - {IssueSeverity::WARNING, "WARNING"}, {IssueSeverity::RECOVERABLE, "RECOVERABLE"}, - {IssueSeverity::ERROR, "ERROR"}, {IssueSeverity::FATAL, "FATAL"}, - {IssueSeverity::ALWAYS, "ALWAYS"}}; - - static const std::map<std::string, IssueSeverity::Level> s_levelSTrans = { - {"VERBOSE", IssueSeverity::VERBOSE}, {"DEBUG", IssueSeverity::DEBUG}, - {"DEBUG1", IssueSeverity::DEBUG1}, {"DEBUG2", IssueSeverity::DEBUG2}, - {"DEBUG3", IssueSeverity::DEBUG3}, {"INFO", IssueSeverity::INFO}, - {"WARNING", IssueSeverity::WARNING}, {"RECOVERABLE", IssueSeverity::RECOVERABLE}, - {"ERROR", IssueSeverity::ERROR}, {"FATAL", IssueSeverity::FATAL}, - {"ALWAYS", IssueSeverity::ALWAYS}}; -} - -DECLARE_COMPONENT( IssueLogger ) - -//*************************************************************************// -inline void toupper( std::string& s ) { std::transform( s.begin(), s.end(), s.begin(), (int ( * )( int ))toupper ); } - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -IssueLogger::IssueLogger( const std::string& name, ISvcLocator* svc ) : base_class( name, svc ) -{ - - m_reportLevelS.declareUpdateHandler( &IssueLogger::setupLevels, this ); - m_traceLevelS.declareUpdateHandler( &IssueLogger::setupLevels, this ); - m_outputfile.declareUpdateHandler( &IssueLogger::setupStreams, this ); - - m_reportLevel = IssueSeverity::WARNING; - m_traceLevel = IssueSeverity::ERROR; -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -StatusCode IssueLogger::initialize() -{ - - StatusCode st = Service::initialize(); - if ( st.isSuccess() ) { - setupDefaultLogger(); - } - return st; -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -StatusCode IssueLogger::reinitialize() -{ - - warning() << "reinitialize not implemented" << endmsg; - return StatusCode::SUCCESS; -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -StatusCode IssueLogger::finalize() -{ - - debug() << "IssueLogger::finalize" << endmsg; - std::for_each( std::begin( m_log ), std::end( m_log ), []( logger_t& i ) { i.reset(); } ); - return Service::finalize(); -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -StatusCode IssueLogger::connect( const std::string& ident ) -{ - - auto loc = ident.find( " " ); - using Parser = Gaudi::Utils::AttribStringParser; - // note: if loc == string::npos then loc + 1 == 0 - for ( auto attrib : Parser( ident.substr( loc + 1 ) ) ) { - toupper( attrib.tag ); - IssueSeverity::Level level; - if ( attrib.tag == "DEBUG" ) { - level = IssueSeverity::DEBUG; - } else if ( attrib.tag == "INFO" ) { - level = IssueSeverity::INFO; - } else if ( attrib.tag == "WARNING" ) { - level = IssueSeverity::WARNING; - } else if ( attrib.tag == "RECOVERABLE" ) { - level = IssueSeverity::RECOVERABLE; - } else if ( attrib.tag == "ERROR" ) { - level = IssueSeverity::ERROR; - } else if ( attrib.tag == "FATAL" ) { - level = IssueSeverity::FATAL; - } else { - error() << "Unknown output level \"" << attrib.tag << "\"" << endmsg; - continue; - } - - if ( m_log[level] ) { - info() << "closing stream " << m_log[level].name() << endmsg; - m_log[level].reset(); - } - - if ( attrib.value == "MsgSvc" ) { - m_log[level] = {new StreamLogger( msgSvc(), s_sevMsgMap.at( level ) ), &StreamLogger::WriteToMsgSvc}; - } else if ( attrib.value == "STDERR" ) { - m_log[level] = {new StreamLogger( std::cerr ), &StreamLogger::WriteToStream}; - } else if ( attrib.value == "STDOUT" ) { - m_log[level] = {new StreamLogger( std::cout ), &StreamLogger::WriteToStream}; - } else { // A file - try { - m_log[level] = {new StreamLogger( attrib.value ), &StreamLogger::WriteToStream}; - } catch ( std::exception& ) { - m_log[level].reset(); - error() << "Unable to open file \"" << attrib.value << "\" for writing issues at level " << attrib.tag - << endmsg; - return StatusCode::FAILURE; - } - } - debug() << "Writing " << s_levelTrans.at( level ) << " issues to " << m_log[level].name() << endmsg; - } - return StatusCode::SUCCESS; -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -void IssueLogger::report( IssueSeverity::Level lev, const std::string& str, const std::string& org ) -{ - if ( lev < m_reportLevel ) return; - std::string msg = s_levelTrans.at( lev ) + " " + org + " \"" + str + "\""; - if ( m_showTime ) msg += " [" + Gaudi::Time::current().format( true, "%H:%M:%S %Y/%m/%d %Z" ) + "]"; - if ( lev >= m_traceLevel ) msg += "\n" + getTraceBack(); - m_log[lev]( msg ); -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -void IssueLogger::report( const IssueSeverity& err ) { report( err.getLevel(), err.getMsg(), err.getOrigin() ); } - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -void IssueLogger::setupLevels( Gaudi::Details::PropertyBase& prop ) -{ - - Gaudi::Property<std::string>* sap = dynamic_cast<Gaudi::Property<std::string>*>( &prop ); - if ( !sap ) { - error() << "Could not convert " << prop.name() << "to a Gaudi::Property<std::string> (which it should be!)" - << endmsg; - return; - } - - const std::string& val = sap->value(); - auto set = [&]( IssueSeverity::Level& key, IssueSeverity::Level def ) { - if ( s_levelSTrans.find( val ) == s_levelSTrans.end() ) { - key = def; - error() << "Option " << prop.name() << ": unknown Issue Severity level \"" << val << "\". Setting it " - << s_levelTrans.at( def ) << endmsg; - } else { - key = s_levelSTrans.at( val ); - } - }; - - if ( prop.name() == "ReportLevel" ) { - set( m_reportLevel, IssueSeverity::WARNING ); - } else if ( prop.name() == "TracebackLevel" ) { - set( m_traceLevel, IssueSeverity::ERROR ); - } else { - error() << "setting up unknown property \"" << prop.name() << "\"" << endmsg; - } -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -void IssueLogger::setupStreams( Gaudi::Details::PropertyBase& prop ) -{ - - Gaudi::Property<std::vector<std::string>>* sap = dynamic_cast<Gaudi::Property<std::vector<std::string>>*>( &prop ); - if ( !sap ) { - error() << "Could not convert " << prop.name() - << "to a Gaudi::Property<std::vector<std::string>> (which it should be!)" << endmsg; - return; - } - for ( const auto& s : sap->value() ) { - if ( connect( s ).isFailure() ) { - error() << "Could not setup stream " << s << endmsg; - } - } -} - -//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *// - -void IssueLogger::setupDefaultLogger() -{ - for ( int i = 1; i < IssueSeverity::NUM_LEVELS; ++i ) { - if ( !m_log[i] ) { - // default: dump to msgSvc - IssueSeverity::Level j = IssueSeverity::Level( i ); - m_log[j] = {new StreamLogger( msgSvc(), s_sevMsgMap.at( j ) ), &StreamLogger::WriteToMsgSvc}; - debug() << "Writing " << s_levelTrans.at( j ) << " issues to " << m_log[j].name() << endmsg; - } - } -} diff --git a/GaudiMonitor/src/IssueLogger.h b/GaudiMonitor/src/IssueLogger.h deleted file mode 100644 index d7910c89db..0000000000 --- a/GaudiMonitor/src/IssueLogger.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef GAUDISVC_ISSUELOGGER_H -#define GAUDISVC_ISSUELOGGER_H - -#include "GaudiKernel/IIssueLogger.h" -#include "GaudiKernel/IssueSeverity.h" -#include "GaudiKernel/Property.h" -#include "GaudiKernel/Service.h" -#include "StreamLogger.h" -#include <map> -#include <string> -#include <vector> - -class IssueLogger : public extends<Service, IIssueLogger> -{ -public: - IssueLogger( const std::string& name, ISvcLocator* svc ); - ~IssueLogger() override = default; - - StatusCode initialize() override; - StatusCode reinitialize() override; - StatusCode finalize() override; - - void report( IssueSeverity::Level level, const std::string& msg, const std::string& origin ) override; - void report( const IssueSeverity& err ) override; - -private: - Gaudi::Property<std::vector<std::string>> m_outputfile{this, "Output"}; - Gaudi::Property<std::string> m_reportLevelS{this, "ReportLevel", "WARNING"}; - Gaudi::Property<std::string> m_traceLevelS{this, "TracebackLevel", "ERROR"}; - Gaudi::Property<bool> m_showTime{this, "ShowTime", false}; - - IssueSeverity::Level m_reportLevel, m_traceLevel; - - class logger_t final - { - std::unique_ptr<StreamLogger> m_logger; - void ( StreamLogger::*m_fun )( const std::string& ) = nullptr; - - public: - logger_t() = default; - logger_t( StreamLogger* logger, void ( StreamLogger::*fun )( const std::string& ) ) : m_logger{logger}, m_fun{fun} - { - } - void operator()( const std::string& s ) const { ( m_logger.get()->*m_fun )( s ); } - const std::string& name() const { return m_logger->name(); } - explicit operator bool() const { return bool( m_logger ); } - void reset() { m_logger.reset(); } - }; - std::array<logger_t, IssueSeverity::NUM_LEVELS> m_log; - - StatusCode connect( const std::string& ); - void setupDefaultLogger(); - void setupLevels( Gaudi::Details::PropertyBase& prop ); - void setupStreams( Gaudi::Details::PropertyBase& prop ); -}; - -#endif diff --git a/GaudiMonitor/src/StreamLogger.cpp b/GaudiMonitor/src/StreamLogger.cpp deleted file mode 100644 index 1eac6f27d4..0000000000 --- a/GaudiMonitor/src/StreamLogger.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "StreamLogger.h" -#include <fstream> - -StreamLogger::StreamLogger( const std::string& file ) - : m_name{"file:" + file}, m_oost{new std::ofstream( file )}, m_ost{m_oost.get()} -{ - if ( !m_oost ) throw std::invalid_argument( "can't open file" ); -} - -StreamLogger::StreamLogger( IMessageSvc* svc, MSG::Level lev ) - : m_name{"MsgStream"}, m_msgStr{new MsgStream( svc, "IssueLogger" )}, m_level{lev} -{ -} - -StreamLogger::StreamLogger( std::ostream& ost ) - : m_name{&ost == &std::cerr ? "STDERR" : &ost == &std::cout ? "STDOUT" : "unknown ostream"}, m_ost{&ost} -{ -} diff --git a/GaudiMonitor/src/StreamLogger.h b/GaudiMonitor/src/StreamLogger.h deleted file mode 100644 index 5b42deb114..0000000000 --- a/GaudiMonitor/src/StreamLogger.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GAUDISVC_STREAMLOGGER_H -#define GAUDISVC_STREAMLOGGER_H - -#include "GaudiKernel/MsgStream.h" - -#include <ostream> -#include <string> - -class IMessageSvc; - -class StreamLogger final -{ -public: - StreamLogger( const std::string& file ); - StreamLogger( std::ostream& ost ); - StreamLogger( IMessageSvc*, MSG::Level ); - - const std::string& name() const { return m_name; } - - void WriteToStream( const std::string& str ) { *m_ost << str << std::endl; } - void WriteToMsgSvc( const std::string& str ) { *m_msgStr << m_level << str << endmsg; } - -private: - std::string m_name; - std::unique_ptr<std::ostream> m_oost; - std::ostream* m_ost = nullptr; - std::unique_ptr<MsgStream> m_msgStr; - MSG::Level m_level = MSG::NIL; -}; - -#endif diff --git a/GaudiSvc/doc/IssueLogger.txt b/GaudiSvc/doc/IssueLogger.txt deleted file mode 100644 index d9311b2bab..0000000000 --- a/GaudiSvc/doc/IssueLogger.txt +++ /dev/null @@ -1,110 +0,0 @@ - -IssueLogger -=========== - -Available Job Options: - (StringArray) Output - (Integer) ReportLevel - (Integer) TracebackLevel - (Boolean) ShowTime - - - -The IssueLogger service makes use of the IssueSeverity object, to -automatically record and stream errors to various outputs. - -IssueSeverity objects are created using the macro "ISSUE", -with two parameters: the error level, and a message. eg: - - ISSUE(Severity::WARNING,"track Chi2 is too high"); - -The available error levels are: - - VERBOSE, - DEBUG, - DEBUG1, - DEBUG2, - DEBUG3, - INFO, - WARNING, - RECOVERABLE, - ERROR, - FATAL - -which are enums in the "Severity" namespace, as defined in -GaudiKernel/IssueSeverity.h. - -The ISSUE macro wraps an IssueSeverity object, and inserts -the file and line number where the object was created. The -constructor of the IssueSeverity object passes this information -to the IssueLogger, which passes it to the appropriate stream, -and appends a stack traceback if desired. - -The IssueLogger output streams are defined at run time, via -jobOptions: - -IssueLogger.Output = {"_Level_='_StreamType_'"}; - - -where _Level_ can be one of - - VERBOSE, - DEBUG, - DEBUG1, - DEBUG2, - DEBUG3, - INFO, - WARNING, - RECOVERABLE, - ERROR, - FATAL - -(ie, the same as the Severity levels), and the _StreamType_ -can be one of - MsgSvc : write to the message service - STDOUT : write to the standard out - STDERR : write to the standard error - a file name : write to a file - -eg: - -IssueLogger.Output = {"DEBUG='MsgSvc'"}; -IssueLogger.Output += {"WARNING='warnings.out'"}; -IssueLogger.Output += {"ERROR='STDERR'"}; - -The default output stream is "MsgSvc". When streaming to the MsgSvc, -the message level used is the same as the that of the IssueSeverity, -ie an IssueSeverity::WARNING object will be written with a -MSG::WARNING message. - -The level of reporting is controlled via two options: "ReportLevel", -and "TraceBackLevel". "ReportLevel" controls the level at which -messages are written out, eg if it's set to INFO, only INFO and -higher ErrorObjects are written out to whatever stream they're -associated with. The "TraceBackLevel" option controls the level at -which a stack trace is attached to the message. - - -IssueSeverity objects can be attached to StatusCodes, either via -the constructor of the StatusCode, or with the conversion operator: - StatusCode sc(StatusCode::FAILURE, - ISSUE(Severity::ERROR,"HV set too low!")); - - - StatusCode sc(ISSUE(Severity::WARNING,"fit parameters off")); - -when the conversion operator is used (ie, the second case), the -IssueSeverity level is used to set the type of the -StatusCode. Anything of WARNING level and down, is set to a -StatusCode::SUCCESS, a RECOVERABLE is set as a StatusCode::RECOVERABLE, -and anything above that is set to a StatusCode::FAILURE. - -Attaching an ISSUE to a StatusCode does not obviate the need to check -whether the StatusCode is a success or failure! - -The IssueSeverity object can be retrieved from a StatusCode using the -StatusCode::severity() method. - - -A timestamp can be printed along with the error message, by setting -the boolean jobOption "ShowTime" to "true". \ No newline at end of file diff --git a/GaudiUtils/src/component/XMLFileCatalog.h b/GaudiUtils/src/component/XMLFileCatalog.h index 9c1d928062..5ac2cdbdf7 100644 --- a/GaudiUtils/src/component/XMLFileCatalog.h +++ b/GaudiUtils/src/component/XMLFileCatalog.h @@ -7,6 +7,8 @@ #include "xercesc/parsers/XercesDOMParser.hpp" #include "xercesc/sax/ErrorHandler.hpp" +#include <memory> + // Forward declarations class IMessageSvc; -- GitLab