![]() |
|
|
Generated: 18 Jul 2008 |
#include <AlgErrorAuditor.h>
Inheritance diagram for AlgErrorAuditor:


Definition at line 16 of file AlgErrorAuditor.h.
Public Member Functions | |
| AlgErrorAuditor (const std::string &name, ISvcLocator *pSvcLocator) | |
| virtual | ~AlgErrorAuditor () |
| virtual StatusCode | initialize () |
| virtual StatusCode | finalize () |
| virtual void | beforeExecute (INamedInterface *alg) |
| virtual void | afterExecute (INamedInterface *alg, const StatusCode &) |
Private Member Functions | |
| void | incrMap (const std::string &algName, int level) |
Private Attributes | |
| BooleanProperty | m_abort |
| BooleanProperty | m_throw |
| int | m_error |
| int | m_fatal |
| std::map< std::string, int > | m_algMap [2] |
| AlgErrorAuditor::AlgErrorAuditor | ( | const std::string & | name, | |
| ISvcLocator * | pSvcLocator | |||
| ) |
Definition at line 14 of file AlgErrorAuditor.cpp.
References Auditor::declareProperty(), m_abort, and m_throw.
00015 : Auditor(name, pSvcLocator), m_error(0), m_fatal(0) { 00016 00017 declareProperty( "Abort", m_abort = false, 00018 "Abort job upon illegal Algorithm return code"); 00019 declareProperty( "Throw", m_throw = false, 00020 "Throw GaudiException upon illegal Algorithm return code"); 00021 }
| AlgErrorAuditor::~AlgErrorAuditor | ( | ) | [virtual] |
| StatusCode AlgErrorAuditor::initialize | ( | ) | [virtual] |
Reimplemented from Auditor.
Definition at line 34 of file AlgErrorAuditor.cpp.
References endreq(), MSG::INFO, m_abort, m_throw, Auditor::msgSvc(), Auditor::name(), and StatusCode::SUCCESS.
00034 { 00035 00036 if (m_abort && m_throw) { 00037 MsgStream log(msgSvc(), name()); 00038 log << MSG::INFO << "Both \"Throw\" and \"Abort\" options have been set." 00039 << " Abort takes precedence." << endreq; 00040 } 00041 00042 return StatusCode::SUCCESS; 00043 }
| StatusCode AlgErrorAuditor::finalize | ( | ) | [virtual] |
Reimplemented from Auditor.
Definition at line 89 of file AlgErrorAuditor.cpp.
References std::endl(), endreq(), MSG::INFO, m_algMap, Auditor::msgSvc(), Auditor::name(), and StatusCode::SUCCESS.
00089 { 00090 00091 00092 std::map<std::string,int>::const_iterator itr; 00093 if (m_algMap[0].size() != 0) { 00094 MsgStream log(msgSvc(), name()); 00095 log << MSG::INFO << "Found " << m_algMap[0].size() 00096 << " instances where an Algorithm::execute() produced an ERROR " 00097 << "but returned a SUCCESS:" << std::endl; 00098 00099 for (itr = m_algMap[0].begin(); itr != m_algMap[0].end(); ++itr) { 00100 log << itr->first << ": " << itr->second << std::endl; 00101 } 00102 00103 log << endreq; 00104 } 00105 00106 if (m_algMap[1].size() != 0) { 00107 MsgStream log(msgSvc(), name()); 00108 log << MSG::INFO << "Found " << m_algMap[1].size() 00109 << " instances where an Algorithm::execute() produced a FATAL " 00110 << "but returned a SUCCESS:" << std::endl; 00111 00112 for (itr = m_algMap[1].begin(); itr != m_algMap[1].end(); ++itr) { 00113 log << itr->first << ": " << itr->second << std::endl; 00114 } 00115 00116 log << endreq; 00117 } 00118 00119 00120 return StatusCode::SUCCESS; 00121 00122 }
| void AlgErrorAuditor::beforeExecute | ( | INamedInterface * | alg | ) | [virtual] |
Reimplemented from Auditor.
Definition at line 28 of file AlgErrorAuditor.cpp.
References MSG::ERROR, MSG::FATAL, m_error, m_fatal, IMessageSvc::messageCount(), and Auditor::msgSvc().
00028 { 00029 m_error = msgSvc()->messageCount(MSG::ERROR); 00030 m_fatal = msgSvc()->messageCount(MSG::FATAL); 00031 }
| void AlgErrorAuditor::afterExecute | ( | INamedInterface * | alg, | |
| const StatusCode & | ||||
| ) | [virtual] |
Reimplemented from Auditor.
Definition at line 47 of file AlgErrorAuditor.cpp.
References endreq(), MSG::ERROR, StatusCode::FAILURE, MSG::FATAL, incrMap(), StatusCode::isRecoverable(), m_abort, m_error, m_fatal, m_throw, Auditor::msgSvc(), Auditor::name(), INamedInterface::name(), and std::basic_ostringstream< _CharT, _Traits, _Alloc >::str().
00047 { 00048 00049 bool fail(false); 00050 if (msgSvc()->messageCount(MSG::ERROR) != m_error && ! sc.isRecoverable() ) { 00051 std::ostringstream os; 00052 os << "Illegal Return Code: Algorithm " << alg->name() 00053 << " reported an ERROR, but returned a StatusCode \"" << sc << "\""; 00054 00055 MsgStream log(msgSvc(), name()); 00056 log << MSG::ERROR << os.str() << endreq; 00057 incrMap(alg->name(), 0); 00058 fail = true; 00059 00060 if (m_throw && ! m_abort) { 00061 throw GaudiException(os.str(),"AlgErrorAuditor",0); 00062 } 00063 } 00064 00065 if (msgSvc()->messageCount(MSG::FATAL) != m_fatal && 00066 sc != StatusCode::FAILURE ) { 00067 std::ostringstream os; 00068 os << "Illegal Return Code: Algorithm " << alg->name() 00069 << " reported a FATAL, but returned a StatusCode \"" << sc << "\""; 00070 00071 MsgStream log(msgSvc(), name()); 00072 log << MSG::ERROR << os.str() << endreq; 00073 incrMap(alg->name(), 1); 00074 fail = true; 00075 00076 if (m_throw && ! m_abort) { 00077 throw GaudiException(os.str(),"AlgErrorAuditor",0); 00078 } 00079 00080 } 00081 00082 if (fail && m_abort) { 00083 abort(); 00084 } 00085 00086 }
| void AlgErrorAuditor::incrMap | ( | const std::string & | algName, | |
| int | level | |||
| ) | [private] |
Definition at line 125 of file AlgErrorAuditor.cpp.
References find(), and m_algMap.
Referenced by afterExecute().
00125 { 00126 std::map<std::string, int>::iterator itr; 00127 if ( (itr=m_algMap[level].find(alg)) != m_algMap[level].end()) { 00128 itr->second++; 00129 } else { 00130 m_algMap[level].insert( std::pair<std::string,int>(alg,1) ); 00131 } 00132 }
BooleanProperty AlgErrorAuditor::m_abort [private] |
Definition at line 28 of file AlgErrorAuditor.h.
Referenced by afterExecute(), AlgErrorAuditor(), and initialize().
BooleanProperty AlgErrorAuditor::m_throw [private] |
Definition at line 28 of file AlgErrorAuditor.h.
Referenced by afterExecute(), AlgErrorAuditor(), and initialize().
int AlgErrorAuditor::m_error [private] |
int AlgErrorAuditor::m_fatal [private] |
std::map<std::string, int> AlgErrorAuditor::m_algMap[2] [private] |