The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
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
13
#include <
GaudiKernel/GaudiException.h
>
14
#include <
GaudiKernel/MsgStream.h
>
15
16
StatusCode
Gaudi::Auditor::sysInitialize
() {
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
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
}
50
return
StatusCode::FAILURE
;
51
}
52
53
StatusCode
Gaudi::Auditor::sysFinalize
() {
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 ) {
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
}
82
return
StatusCode::FAILURE
;
83
}
Auditor.h
GaudiException.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition
CommonMessaging.h:79
CommonMessaging< implements< IAuditor, IProperty > >::setUpMessaging
MSG::Level setUpMessaging() const override final
Definition
CommonMessaging.h:175
Gaudi::Auditor::m_outputLevel
Gaudi::Property< int > m_outputLevel
Pointer to service locator service.
Definition
Auditor.h:72
Gaudi::Auditor::m_isFinalized
bool m_isFinalized
Auditor has been initialized flag.
Definition
Auditor.h:79
Gaudi::Auditor::m_pSvcLocator
SmartIF< ISvcLocator > m_pSvcLocator
Auditor's name for identification.
Definition
Auditor.h:70
Gaudi::Auditor::name
const std::string & name() const override
Definition
Auditor.h:51
Gaudi::Auditor::m_isInitialized
bool m_isInitialized
Definition
Auditor.h:78
Gaudi::Auditor::initialize
virtual StatusCode initialize()
Definition
Auditor.h:48
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Auditor.h:59
Gaudi::Auditor::sysFinalize
StatusCode sysFinalize() override
Definition
Auditor.cpp:53
Gaudi::Auditor::isEnabled
bool isEnabled() const override
Definition
Auditor.h:52
Gaudi::Auditor::finalize
virtual StatusCode finalize()
Definition
Auditor.h:49
Gaudi::Auditor::sysInitialize
StatusCode sysInitialize() override
Definition
Auditor.cpp:16
GaudiException
Define general base for Gaudi exception.
Definition
GaudiException.h:29
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >::bindPropertiesTo
void bindPropertiesTo(Gaudi::Interfaces::IOptionsSvc &optsSvc)
Definition
PropertyHolder.h:238
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition
StatusCode.h:151
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
MSG::FATAL
@ FATAL
Definition
IMessageSvc.h:22
MSG::ERROR
@ ERROR
Definition
IMessageSvc.h:22
GaudiKernel
src
Lib
Auditor.cpp
Generated on
for The Gaudi Framework by
1.17.0