The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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
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.
22 // this initializes the messaging, in case property update handlers need to print
23 // and update the property value bypassing the update handler
24 m_outputLevel.value() = setUpMessaging();
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 ) {
32 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 ) {
39 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 }
51}
52
54 try {
55 // Invoke the finalize() method of the derived class if
56 // it has been initialized.
58 m_isFinalized = true;
59 return finalize();
60 }
62 } catch ( const GaudiException& Exception ) {
64 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 ) {
72 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 ( ... ) {
79 MsgStream log( msgSvc(), name() + ".sysFinalize()" );
80 log << MSG::FATAL << " UNKNOWN Exception is caught " << endmsg;
81 }
83}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition Auditor.h:72
bool m_isFinalized
Auditor has been initialized flag.
Definition Auditor.h:79
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition Auditor.h:70
const std::string & name() const override
Definition Auditor.h:51
bool m_isInitialized
Definition Auditor.h:78
virtual StatusCode initialize()
Definition Auditor.h:48
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition Auditor.h:59
StatusCode sysFinalize() override
Definition Auditor.cpp:53
bool isEnabled() const override
Definition Auditor.h:52
virtual StatusCode finalize()
Definition Auditor.h:49
StatusCode sysInitialize() override
Definition Auditor.cpp:16
Define general base for Gaudi exception.
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:163
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ FATAL
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22