Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
003faa12
Commit
003faa12
authored
2 years ago
by
Marco Clemencic
Browse files
Options
Downloads
Patches
Plain Diff
Restore original ROOT error handler at terminate
parent
22723973
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1412
Use MessageSvc to handle ROOT messages
Pipeline
#5034639
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
+17
-4
17 additions, 4 deletions
GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
with
17 additions
and
4 deletions
GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
+
17
−
4
View file @
003faa12
...
...
@@ -45,6 +45,8 @@ DECLARE_OBJECT_FACTORY( ApplicationMgr )
namespace
{
/// Pointer to the IMessageSvc instance used by ROOTErrorHandlerAdapter.
static
IMessageSvc
*
s_messageSvcInstance
{
nullptr
};
/// Pointer to the ROOT error handler registered before we replaced it with ROOTErrorHandlerAdapter.
static
ErrorHandlerFunc_t
s_originalRootErrorHandler
{
nullptr
};
/// @brief Adapter to forward ROOT messages to a MessageSvc.
void
ROOTErrorHandlerAdapter
(
int
level
,
Bool_t
abort
,
const
char
*
location
,
const
char
*
msg
)
{
...
...
@@ -57,8 +59,14 @@ namespace {
if
(
msgLevel
>=
s_messageSvcInstance
->
outputLevel
(
location
)
)
s_messageSvcInstance
->
reportMessage
(
Message
{
location
,
msgLevel
,
msg
},
msgLevel
);
}
else
{
// If a message is sent when we do not have an IMessageSvc, let's use a basic implementation from ROOT
ROOT
::
Internal
::
MinimalErrorHandler
(
level
,
abort
,
location
,
msg
);
// If a message is sent when we do not have an IMessageSvc, let's use something else
if
(
s_originalRootErrorHandler
)
{
// either the original handler (if any)
s_originalRootErrorHandler
(
level
,
abort
,
location
,
msg
);
}
else
{
// or some minimalistic implementation from ROOT (just not to loose the message)
ROOT
::
Internal
::
MinimalErrorHandler
(
level
,
abort
,
location
,
msg
);
}
}
}
...
...
@@ -165,8 +173,8 @@ StatusCode ApplicationMgr::i_startup() {
if
(
m_useMessageSvcForROOTMessages
)
{
if
(
gROOT
)
{
// if ROOT is already initialized (usually it is the case) we redirect messages to MessageSvc.
s_messageSvcInstance
=
m_messageSvc
.
get
();
SetErrorHandler
(
ROOTErrorHandlerAdapter
);
s_messageSvcInstance
=
m_messageSvc
.
get
();
s_originalRootErrorHandler
=
SetErrorHandler
(
ROOTErrorHandlerAdapter
);
}
else
{
log
<<
MSG
::
WARNING
<<
"ROOT not yet initialized, we cannot override the error handler are requested "
...
...
@@ -649,6 +657,11 @@ StatusCode ApplicationMgr::terminate() {
opts
.
set
(
"JobOptionsSvc.AuditFinalize"
,
"false"
);
}
// if we have overriden it, restore the original ROOT error handler
if
(
s_originalRootErrorHandler
)
{
SetErrorHandler
(
s_originalRootErrorHandler
);
s_originalRootErrorHandler
=
nullptr
;
}
// make sure ROOTErrorHandlerAdapter (if in use) does not try to use the MessageSvc we are about to delete
s_messageSvcInstance
=
nullptr
;
// finalize MessageSvc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment