ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthToolSupport
AsgMessaging
Root
MsgHelpers.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
9
//
10
// includes
11
//
12
13
#include <
AsgMessaging/MsgHelpers.h
>
14
#include <
AsgMessaging/MessageCheckLocal.h
>
15
#include <
CxxUtils/checker_macros.h
>
16
17
#include <cassert>
18
#include <mutex>
19
#include <unordered_map>
20
21
#ifndef XAOD_STANDALONE
22
#include <GaudiKernel/Bootstrap.h>
23
#include <GaudiKernel/ISvcLocator.h>
24
#include <
AthenaKernel/getMessageSvc.h
>
25
#endif
26
27
//
28
// method implementations
29
//
30
31
namespace
asg
32
{
33
namespace
34
{
47
std::unordered_map<std::string,MsgStream>& packageMsgStreamMap ()
48
{
49
// access is protected through packageMsgMutex()
50
static
std::unordered_map<std::string,MsgStream>
result
ATLAS_THREAD_SAFE
;
51
return
result
;
52
}
53
63
std::recursive_mutex& packageMsgMutex ()
64
{
65
static
std::recursive_mutex
result
;
66
return
result
;
67
}
68
}
69
70
MsgStream& MsgHelpers ::
71
pkgMsgStream (
const
std::string& package)
72
{
73
std::lock_guard<std::recursive_mutex>
lock
{packageMsgMutex()};
74
auto
iter = packageMsgStreamMap().find (package);
75
if
(iter != packageMsgStreamMap().end())
76
return
iter->second;
77
78
const
std::string fullName {
"Package."
+ package};
79
#ifdef XAOD_STANDALONE
80
auto
result = packageMsgStreamMap().emplace (package, fullName);
81
#else
82
auto
result = packageMsgStreamMap().emplace
83
(std::piecewise_construct,
84
std::forward_as_tuple (package),
85
std::forward_as_tuple (
Athena::getMessageSvc
(
Athena::Options::Eager
), fullName));
86
#endif
87
assert (result.second);
88
return
result.first->second;
89
}
90
91
92
93
void
MsgHelpers ::
94
setPkgMsgLevel (
const
std::string& package, MSG::Level level)
95
{
96
std::lock_guard<std::recursive_mutex>
lock
{packageMsgMutex()};
97
pkgMsgStream
(package).setLevel (level);
98
}
99
100
101
102
void
MsgHelpers ::
103
printAllPkgMsgLevels ()
104
{
105
using namespace
msgAsgMessaging;
106
std::lock_guard<std::recursive_mutex>
lock
{packageMsgMutex()};
107
ANA_MSG_INFO
(
"package message levels:"
);
108
for
(
auto
& msgStream : packageMsgStreamMap())
109
{
110
ANA_MSG_INFO
(
" package="
<< msgStream.first <<
" level="
<< name (msgStream.second.level()) <<
"("
<< unsigned (msgStream.second.level()) <<
")"
);
111
}
112
}
113
}
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
MessageCheckLocal.h
MsgHelpers.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::Options::Eager
@ Eager
Definition
getMessageSvc.h:22
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
asg
Definition
DataHandleTestTool.h:28
get_generator_info.result
result
Definition
get_generator_info.py:21
asg::MsgHelpers::pkgMsgStream
static MsgStream & pkgMsgStream(const std::string &package)
the message stream for the given package identifier
Definition
MsgHelpers.cxx:71
Generated on
for ATLAS Offline Software by
1.17.0