The Gaudi Framework  master (f5098d57)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Auditor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <Gaudi/Auditor.h>
12 
14 #include <GaudiKernel/MsgStream.h>
15 
17  // Bypass the initialization if the auditor is disabled or
18  // has already been initialized.
19  if ( isEnabled() && !m_isInitialized ) {
20  // Setup the default service ... this should be upgraded so as to be configurable.
21  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
22  // this initializes the messaging, in case property update handlers need to print
23  // and update the property value bypassing the update handler
25  // Set the Algorithm's properties
26  bindPropertiesTo( serviceLocator()->getOptsSvc() );
27  try {
28  // Invoke the initialize() method of the derived class
29  return initialize().andThen( [&] { m_isInitialized = true; } );
30  } catch ( const GaudiException& Exception ) {
31  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
33  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
35  MsgStream logEx( msgSvc(), Exception.tag() );
36  logEx << MSG::ERROR << Exception << endmsg;
37  } catch ( const std::exception& Exception ) {
38  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
40  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
42  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
43  logEx << MSG::ERROR << Exception.what() << endmsg;
44  } catch ( ... ) {
46  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
47  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
48  }
49  }
50  return StatusCode::FAILURE;
51 }
52 
54  try {
55  // Invoke the finalize() method of the derived class if
56  // it has been initialized.
57  if ( m_isInitialized && !m_isFinalized ) {
58  m_isFinalized = true;
59  return finalize();
60  }
61  return StatusCode::SUCCESS;
62  } catch ( const GaudiException& Exception ) {
63  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
65  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
68  MsgStream logEx( msgSvc(), Exception.tag() );
69  logEx << MSG::ERROR << Exception << endmsg;
70  } catch ( const std::exception& Exception ) {
71  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
73  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
75  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
76  logEx << MSG::ERROR << Exception.what() << endmsg;
77  } catch ( ... ) {
78  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
80  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
81  }
82  return StatusCode::FAILURE;
83 }
Gaudi.Configuration.log
log
Definition: Configuration.py:28
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:164
GaudiException.h
Gaudi::Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition: Auditor.h:70
GaudiException
Definition: GaudiException.h:32
Gaudi::Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition: Auditor.h:72
Gaudi::Auditor::sysFinalize
StatusCode sysFinalize() override
Definition: Auditor.cpp:53
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:255
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
Gaudi::Auditor::m_isInitialized
bool m_isInitialized
Definition: Auditor.h:78
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:59
CommonMessaging< implements< IAuditor, IProperty > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:174
StatusCode
Definition: StatusCode.h:65
Gaudi::Auditor::name
const std::string & name() const override
Definition: Auditor.h:51
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:235
Gaudi::Auditor::sysInitialize
StatusCode sysInitialize() override
Definition: Auditor.cpp:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
MsgStream
Definition: MsgStream.h:33
MSG::FATAL
@ FATAL
Definition: IMessageSvc.h:25
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:48
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
Gaudi::Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:52
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
MsgStream.h
Auditor.h