Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
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 \***********************************************************************************/
13 #include <GaudiKernel/Kernel.h>
14 
15 #include <GaudiKernel/Auditor.h>
16 
18 #include <GaudiKernel/MsgStream.h>
19 
20 // Constructor
22  : m_name( std::move( name ) ), m_pSvcLocator( pSvcLocator ) {}
23 
24 // IAuditor implementation
26  StatusCode sc;
27 
28  // Bypass the initialization if the auditor is disabled or
29  // has already been initialized.
30  if ( isEnabled() && !m_isInitialized ) {
31 
32  // Setup the default service ... this should be upgraded so as to be configurable.
33  if ( !m_pSvcLocator ) return StatusCode::FAILURE;
34 
35  // this initializes the messaging, in case property update handlers need to print
36  // and update the property value bypassing the update handler
38 
39  // Set the Algorithm's properties
40  bindPropertiesTo( serviceLocator()->getOptsSvc() );
41 
42  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
43 
44  {
45  try {
46  // Invoke the initialize() method of the derived class
47  sc = initialize();
48  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
49  m_isInitialized = true;
50 
51  return sc;
52  } catch ( const GaudiException& Exception )
53  {
55  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
56  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is caught " << endmsg;
58  MsgStream logEx( msgSvc(), Exception.tag() );
59  logEx << MSG::ERROR << Exception << endmsg;
60  } catch ( const std::exception& Exception )
61  {
63  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
64  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
66  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
67  logEx << MSG::ERROR << Exception.what() << endmsg;
68  } catch ( ... ) {
70  MsgStream log( msgSvc(), name() + ".sysInitialize()" );
71  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
72  }
73  }
74  }
76  return StatusCode::FAILURE;
77 }
78 
81  try {
82  //
83  // Invoke the finalize() method of the derived class if
84  // it has been initialized.
85  if ( m_isInitialized && !m_isFinalized ) {
86  m_isFinalized = true;
87  sc = finalize();
88  if ( !sc.isSuccess() ) return StatusCode::FAILURE;
89  }
90  return sc;
91  //
92  } catch ( const GaudiException& Exception )
93  {
95  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
96  log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
99  MsgStream logEx( msgSvc(), Exception.tag() );
100  logEx << MSG::ERROR << Exception << endmsg;
101  } catch ( const std::exception& Exception )
102  {
104  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
105  log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
107  MsgStream logEx( msgSvc(), name() + "*std::exception*" );
108  logEx << MSG::ERROR << Exception.what() << endmsg;
109  } catch ( ... )
110  {
112  MsgStream log( msgSvc(), name() + ".sysFinalize()" );
113  log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
114  }
116  return StatusCode::FAILURE;
117 }
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.h:88
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.h:77
std::string
STL class.
std::exception
STL class.
Gaudi.Configuration.log
log
Definition: Configuration.py:28
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:315
GaudiException.h
ISvcLocator
Definition: ISvcLocator.h:46
Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Auditor.h:115
GaudiException
Definition: GaudiException.h:32
IMessageSvc.h
Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Pointer to service locator service.
Definition: Auditor.h:113
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition: PropertyHolder.h:252
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
CommonMessaging< implements< IAuditor, IProperty > >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:174
Auditor::m_isFinalized
bool m_isFinalized
Auditor has been finalized flag.
Definition: Auditor.h:122
StatusCode
Definition: StatusCode.h:65
Auditor::sysFinalize
StatusCode sysFinalize() override
Finalization method invoked by the framework.
Definition: Auditor.cpp:79
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:234
Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.h:78
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
Auditor::isEnabled
bool isEnabled() const override
Definition: Auditor.h:82
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
std
STL namespace.
Kernel.h
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
Auditor::Auditor
Auditor(std::string name, ISvcLocator *svcloc)
Constructor.
Definition: Auditor.cpp:21
Auditor::m_isInitialized
bool m_isInitialized
Auditor has been initialized flag.
Definition: Auditor.h:121
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Auditor::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Auditor.cpp:25
ISvcLocator.h
Auditor::name
const std::string & name() const override
Definition: Auditor.h:80
MsgStream.h
Auditor.h