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
df1a970b
Commit
df1a970b
authored
2 years ago
by
Marco Clemencic
Browse files
Options
Downloads
Patches
Plain Diff
Use MessageSvc to handle ROOT messages
parent
db183448
No related branches found
No related tags found
1 merge request
!1412
Use MessageSvc to handle ROOT messages
Pipeline
#5024868
failed
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
+48
-24
48 additions, 24 deletions
GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
with
48 additions
and
24 deletions
GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
+
48
−
24
View file @
df1a970b
/***********************************************************************************\
* (c) Copyright 1998-20
19
CERN for the benefit of the LHCb and ATLAS collaborations *
* (c) Copyright 1998-20
23
CERN for the benefit of the LHCb and ATLAS collaborations *
* *
* This software is distributed under the terms of the Apache version 2 licence, *
* copied verbatim in the file "LICENSE". *
...
...
@@ -9,44 +9,61 @@
* or submit itself to any jurisdiction. *
\***********************************************************************************/
// Include files
#include
"ApplicationMgr.h"
#include
"AlgorithmManager.h"
#include
"DLLClassManager.h"
#include
"ServiceManager.h"
#include
"GaudiKernel/IMessageSvc.h"
#include
"GaudiKernel/IRunable.h"
#include
"GaudiKernel/IService.h"
#include
"GaudiKernel/TypeNameString.h"
#include
"GaudiKernel/MsgStream.h"
#include
"GaudiKernel/ObjectFactory.h"
#include
"GaudiKernel/SmartIF.h"
#include
"GaudiKernel/GaudiException.h"
#include
"GaudiKernel/StatusCode.h"
#include
"GaudiKernel/System.h"
#include
"GaudiKernel/Time.h"
#include
"GAUDI_VERSION.h"
using
System
::
getEnv
;
using
System
::
isEnvSet
;
#include
<GAUDI_VERSION.h>
#include
<GaudiKernel/GaudiException.h>
#include
<GaudiKernel/IMessageSvc.h>
#include
<GaudiKernel/IRunable.h>
#include
<GaudiKernel/IService.h>
#include
<GaudiKernel/Message.h>
#include
<GaudiKernel/MsgStream.h>
#include
<GaudiKernel/ObjectFactory.h>
#include
<GaudiKernel/SmartIF.h>
#include
<GaudiKernel/StatusCode.h>
#include
<GaudiKernel/System.h>
#include
<GaudiKernel/Time.h>
#include
<GaudiKernel/TypeNameString.h>
#include
<TError.h>
#include
<TROOT.h>
#include
<algorithm>
#include
<cassert>
#include
<ctime>
#include
<limits>
#include
<sstream>
using
System
::
getEnv
;
using
System
::
isEnvSet
;
#define ON_DEBUG if ( m_outputLevel <= MSG::DEBUG )
#define ON_VERBOSE if ( m_outputLevel <= MSG::VERBOSE )
DECLARE_OBJECT_FACTORY
(
ApplicationMgr
)
namespace
{
/// Pointer to the IMessageSvc instance used by ROOTErrorHandlerAdapter.
static
IMessageSvc
*
s_messageSvcInstance
{
nullptr
};
/// @brief Adapter to forward ROOT messages to a MessageSvc.
void
ROOTErrorHandlerAdapter
(
int
level
,
Bool_t
abort
,
const
char
*
location
,
const
char
*
msg
)
{
if
(
s_messageSvcInstance
)
{
// # Map ROOT level to Gaudi level:
// ROOT levels go from 0 to 6000 in step of 1000,
// kInfo is 1000 while MSG::INFO is 3, so we aim for `level / 1000 + 2`,
// but we have to put a cap at MSG::FATAL.
int
msgLevel
=
std
::
min
<
int
>
(
level
/
1000
+
2
,
MSG
::
FATAL
);
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
);
}
}
}
// namespace
// Implementation class for the Application Manager. In this way the
// ApplicationMgr class is a fully insulated concrete class. Clients
// (main programs) will not need to re-compile if there are changes
...
...
@@ -145,6 +162,11 @@ StatusCode ApplicationMgr::i_startup() {
log
<<
MSG
::
FATAL
<<
"Error setting OutputLevel option of MessageSvc"
<<
endmsg
;
return
sc
;
}
if
(
gROOT
)
{
// if ROOT is already initialized (usually it is the case) we redirect messages to MessageSvc.
s_messageSvcInstance
=
m_messageSvc
.
get
();
SetErrorHandler
(
ROOTErrorHandlerAdapter
);
}
auto
jobsvc
=
svcManager
()
->
createService
(
Gaudi
::
Utils
::
TypeNameString
(
"JobOptionsSvc"
,
m_jobOptionsSvcType
)
);
// Create the Job Options service
...
...
@@ -620,6 +642,8 @@ StatusCode ApplicationMgr::terminate() {
opts
.
set
(
"JobOptionsSvc.AuditFinalize"
,
"false"
);
}
// make sure ROOTErrorHandlerAdapter (if in use) does not try to use the MessageSvc we are about to delete
s_messageSvcInstance
=
nullptr
;
// finalize MessageSvc
auto
svc
=
m_messageSvc
.
as
<
IService
>
();
if
(
!
svc
)
{
...
...
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