ATLAS Offline Software
Loading...
Searching...
No Matches
asg::MsgHelpers Struct Referencefinal

a helper class for functions dealing with messages More...

#include <MsgHelpers.h>

Collaboration diagram for asg::MsgHelpers:

Static Public Member Functions

static MsgStream & pkgMsgStream (const std::string &package)
 the message stream for the given package identifier
static void setPkgMsgLevel (const std::string &package, MSG::Level level)
 set the package message level for the given name
static void printAllPkgMsgLevels ()
 print all package message levels

Detailed Description

a helper class for functions dealing with messages

This class contains only static member functions and it is solely meant as a work-around for a limitation in ROOT dictionaries: python/root will not autoload a dictionary when a function contained in that dictionary is requested. However, if the function is a static member function of a class it will work just fine, so instead of standalone functions these are now all static member functions.

Definition at line 30 of file MsgHelpers.h.

Member Function Documentation

◆ pkgMsgStream()

MsgStream & asg::MsgHelpers::pkgMsgStream ( const std::string & package)
static

the message stream for the given package identifier

This is for package-level streaming, which in itself is discouraged, but sometimes it is just not practical to wrap code that wants to write out a message into a tool or algorithm. Maybe if we have dual-use services some day, this may become less relevant.

Normally users shouldn't access this directly, but rely on the wrappers defined above.

Definition at line 70 of file MsgHelpers.cxx.

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 }
IMessageSvc * getMessageSvc(bool quiet=false)

◆ printAllPkgMsgLevels()

void asg::MsgHelpers::printAllPkgMsgLevels ( )
static

print all package message levels

This is mostly to have a single, stable function that can be called from python-configuration, without having to rely on any of the details of the implementation above.

Definition at line 102 of file MsgHelpers.cxx.

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 }
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.

◆ setPkgMsgLevel()

void asg::MsgHelpers::setPkgMsgLevel ( const std::string & package,
MSG::Level level )
static

set the package message level for the given name

This is mostly to have a single, stable function that can be called from python-configuration, without having to rely on any of the details of the implementation above.

Definition at line 93 of file MsgHelpers.cxx.

95 {
96 std::lock_guard<std::recursive_mutex> lock {packageMsgMutex()};
97 pkgMsgStream (package).setLevel (level);
98 }
static MsgStream & pkgMsgStream(const std::string &package)
the message stream for the given package identifier

The documentation for this struct was generated from the following files: