ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMessageSvc Class Reference

MessageSvc used by the HLT applications. More...

#include <TrigMessageSvc.h>

Inheritance diagram for TrigMessageSvc:

Classes

struct  MsgAry
 Private helper class to keep the count of messages of a type (MSG::LEVEL). More...

Public Types

typedef std::map< std::string, int, std::less<> > ThresholdMap

Public Member Functions

 TrigMessageSvc (const std::string &name, ISvcLocator *svcloc)
virtual StatusCode reinitialize () override
virtual StatusCode initialize () override
virtual StatusCode start () override
virtual StatusCode stop () override
virtual StatusCode finalize () override
virtual void handle (const Incident &incident) override
virtual void reportMessage (const Message &message) override
virtual void reportMessage (const Message &msg, int outputLevel) override
virtual void reportMessage (std::string source, int type, std::string message) override
virtual std::ostream *defaultStream ATLAS_NOT_CONST_THREAD_SAFE () const override
virtual void setDefaultStream (std::ostream *stream) override
virtual int outputLevel () const override
virtual int outputLevel (std::string_view source) const override
virtual void setOutputLevel (int new_level) override
virtual void setOutputLevel (std::string_view source, int new_level) override
virtual int messageCount (MSG::Level logLevel) const override
virtual bool useColor () const override
virtual std::string getLogColor (int) const override
virtual void reportMessage (const StatusCode &, std::string_view) override
 Not supported by this implementation.
virtual void insertMessage (const StatusCode &, Message) override
virtual void eraseMessage () override
virtual void eraseMessage (const StatusCode &) override
virtual void eraseMessage (const StatusCode &, const Message &) override
virtual void insertStream (int, std::string, std::ostream *) override
virtual void eraseStream () override
virtual void eraseStream (int) override
virtual void eraseStream (int, std::ostream *) override
virtual void eraseStream (std::ostream *) override

Private Member Functions

void setupLimits (Gaudi::Details::PropertyBase &prop)
void setupThreshold (Gaudi::Details::PropertyBase &prop)
bool passErsFilter (const std::string &source, const std::vector< std::string > &filter) const
bool passErsLimit (const Message &msg)
void i_reportMessage (const Message &msg, int outputLevel)
 Internal implementation of reportMessage(const Message&,int) without lock.
void i_reportERS (const Message &msg) const
 Report message to online messaging system (ERS).
void asyncReporting ()
void bookHistograms ()

Private Attributes

Gaudi::Property< std::string > m_defaultFormat
Gaudi::Property< std::string > m_ersFormat
Gaudi::Property< std::string > m_defaultTimeFormat
Gaudi::Property< bool > m_stats {this, "showStats", false, "Show message statistics"}
Gaudi::Property< unsigned int > m_statLevel
Gaudi::Property< unsigned int > m_publishLevel
Gaudi::Property< unsigned int > m_eventIDLevel
Gaudi::Property< bool > m_color
Gaudi::Property< bool > m_suppress {this, "enableSuppression", false, "Enable message suppression"}
Gaudi::Property< bool > m_suppressRunningOnly
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_useERS
 Special properties to control output to ERS of individual sources.
Gaudi::Property< int > m_ersEventLimit
std::ostream * m_defaultStream = &std::cout
 Pointer to the output stream.
ThresholdMap m_thresholdMap
 Output level threshold map.
std::map< std::string, MsgAry > m_sourceMap
 counts per source
std::array< int, MSG::NUM_LEVELS > m_msgCount {}
 counts per level
std::map< size_t, unsigned int > m_msgHashCount
 counts per message hash
std::unordered_map< EventContext::ContextID_t, std::pair< EventContext::ContextEvt_t, MsgAry > > m_slotMsgCount
 counts per slot and level
bool m_doPublish {false}
 are we publishing message statistics?
bool m_doSuppress {false}
 is suppression currently enabled?
TH1I * m_msgCountHist {nullptr}
 Message counting per level histogram.
TH2I * m_msgCountSrcHist {nullptr}
 Message counting per message source.
std::recursive_mutex m_thresholdMapMutex
bool m_asyncReporting {false}
 (
std::thread m_thread
 Thread for asynchronous reporting.
tbb::concurrent_bounded_queue< std::function< void()> > m_messageActionsQueue

Detailed Description

MessageSvc used by the HLT applications.

This MessageSvc implementation it used by the HLT applications. It has some additional features compared to the default Gaudi MessageSvc. Most notably the forwarding of messages to the TDAQ ERS message system.

The message suppression is configured with the following parameters:

Parameters
<level>Limit= 0: no message suppression for <level>
<level>Limit= N > 0: suppress messages after N messages (per source)
<level>Limit= -N < 0: use logarithmic suppression after N messages (per message)

Note, that the logarithmic suppression works on a per-message basis (ignoring any digits in the message).

Author
Iain Last, Werner Wiedenmann, Frank Winklmeier

Definition at line 57 of file TrigMessageSvc.h.

Member Typedef Documentation

◆ ThresholdMap

typedef std::map<std::string, int, std::less<> > TrigMessageSvc::ThresholdMap

Definition at line 59 of file TrigMessageSvc.h.

Constructor & Destructor Documentation

◆ TrigMessageSvc()

TrigMessageSvc::TrigMessageSvc ( const std::string & name,
ISvcLocator * svcloc )

Definition at line 36 of file TrigMessageSvc.cxx.

36 :
37 base_class(name, svcloc)
38{
39 m_outputLevel.declareUpdateHandler([svcloc](Gaudi::Details::PropertyBase&) {
40 SmartIF<IAppMgrUI> app = svcloc;
41 if (app) app->outputLevelUpdate();
42 });
43
44 for (int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
45 m_msgLimit[ic].declareUpdateHandler(&TrigMessageSvc::setupLimits, this);
46 m_thresholdProp[ic].declareUpdateHandler(&TrigMessageSvc::setupThreshold, this);
47 }
48
49 std::fill(std::begin(m_msgCount), std::end(m_msgCount), 0);
50}
void setupLimits(Gaudi::Details::PropertyBase &prop)
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
void setupThreshold(Gaudi::Details::PropertyBase &prop)
std::array< int, MSG::NUM_LEVELS > m_msgCount
counts per level
int ic
Definition grepfile.py:33

Member Function Documentation

◆ asyncReporting()

void TrigMessageSvc::asyncReporting ( )
private

Definition at line 268 of file TrigMessageSvc.cxx.

269{
270 m_asyncReporting = true;
271 std::function<void()> action;
272 while ( m_asyncReporting || !m_messageActionsQueue.empty() ) {
273 m_messageActionsQueue.pop(action);
274 action();
275 }
276}
tbb::concurrent_bounded_queue< std::function< void()> > m_messageActionsQueue

◆ ATLAS_NOT_CONST_THREAD_SAFE()

virtual std::ostream *defaultStream TrigMessageSvc::ATLAS_NOT_CONST_THREAD_SAFE ( ) const
inlineoverridevirtual

Definition at line 73 of file TrigMessageSvc.h.

74 {
75 return m_defaultStream;
76 }
std::ostream * m_defaultStream
Pointer to the output stream.

◆ bookHistograms()

void TrigMessageSvc::bookHistograms ( )
private

Definition at line 112 of file TrigMessageSvc.cxx.

113{
114 ServiceHandle<ITHistSvc> histSvc("THistSvc", name());
115 if ( histSvc.retrieve().isFailure() ) {
116 reportMessage(name(), MSG::WARNING, "Cannot find THistSvc. Message stats will not be published.");
117 m_doPublish = false;
118 return;
119 }
120
121 // monitoring information root directory
122 const std::string path = "/EXPERT/HLTFramework/" + name() + "/";
123 const int nLevelBins = MSG::NUM_LEVELS - m_publishLevel;
124 m_msgCountHist = new TH1I("MessageCount", "Messages while RUNNING;Severity;Count",
125 nLevelBins, 0, nLevelBins);
126
127 const int nSrcBins = 1;
128 m_msgCountSrcHist = new TH2I("MessageCountBySource", "Messages while RUNNING;Severity;Source",
129 nLevelBins, 0, nLevelBins, nSrcBins, 0, nSrcBins);
130
131 for (int i=m_publishLevel; i<MSG::NUM_LEVELS; i++) {
132 m_msgCountHist->GetXaxis()->SetBinLabel(i-m_publishLevel+1, levelNames[i].c_str());
133 m_msgCountSrcHist->GetXaxis()->SetBinLabel(i-m_publishLevel+1, levelNames[i].c_str());
134 }
135
136 if ( histSvc->regHist(path + m_msgCountHist->GetName(), m_msgCountHist).isFailure() ) {
137 reportMessage(name(), MSG::WARNING, "Cannot register monitoring histogram 'MessageCount'");
138 }
139 if ( histSvc->regHist(path + m_msgCountSrcHist->GetName(), m_msgCountSrcHist).isFailure() ) {
140 reportMessage(name(), MSG::WARNING, "Cannot register monitoring histogram 'MessageCountBySource'");
141 }
142}
static constexpr std::string levelNames[MSG::NUM_LEVELS]
virtual void reportMessage(const Message &message) override
TH1I * m_msgCountHist
Message counting per level histogram.
bool m_doPublish
are we publishing message statistics?
TH2I * m_msgCountSrcHist
Message counting per message source.
Gaudi::Property< unsigned int > m_publishLevel
path
python interpreter configuration --------------------------------------—
Definition athena.py:130

◆ eraseMessage() [1/3]

virtual void TrigMessageSvc::eraseMessage ( )
inlineoverridevirtual

Definition at line 96 of file TrigMessageSvc.h.

96{ NOTSUPPORTED; }
#define NOTSUPPORTED

◆ eraseMessage() [2/3]

virtual void TrigMessageSvc::eraseMessage ( const StatusCode & )
inlineoverridevirtual

Definition at line 97 of file TrigMessageSvc.h.

97{ NOTSUPPORTED; }

◆ eraseMessage() [3/3]

virtual void TrigMessageSvc::eraseMessage ( const StatusCode & ,
const Message &  )
inlineoverridevirtual

Definition at line 98 of file TrigMessageSvc.h.

98{ NOTSUPPORTED; }

◆ eraseStream() [1/4]

virtual void TrigMessageSvc::eraseStream ( )
inlineoverridevirtual

Definition at line 100 of file TrigMessageSvc.h.

100{ NOTSUPPORTED; }

◆ eraseStream() [2/4]

virtual void TrigMessageSvc::eraseStream ( int )
inlineoverridevirtual

Definition at line 101 of file TrigMessageSvc.h.

101{ NOTSUPPORTED; }

◆ eraseStream() [3/4]

virtual void TrigMessageSvc::eraseStream ( int ,
std::ostream *  )
inlineoverridevirtual

Definition at line 102 of file TrigMessageSvc.h.

102{ NOTSUPPORTED; }

◆ eraseStream() [4/4]

virtual void TrigMessageSvc::eraseStream ( std::ostream * )
inlineoverridevirtual

Definition at line 103 of file TrigMessageSvc.h.

103{ NOTSUPPORTED; }

◆ finalize()

StatusCode TrigMessageSvc::finalize ( )
overridevirtual

Definition at line 205 of file TrigMessageSvc.cxx.

206{
207 m_suppress = false;
208 std::ostringstream os;
209
210 if (m_stats) {
211 os << "Summarizing all message counts"
212 << " (severity >= " << levelNames[m_statLevel] << ")" << std::endl;
213 }
214 else {
215 os << "Listing sources of suppressed message: " << std::endl;
216 }
217
218 os << "=====================================================" << std::endl;
219 os << " Message Source | Level | Count" << std::endl;
220 os << "-----------------------------+---------+-------------" << std::endl;
221
222 bool found(false);
223
224 for (auto itr = m_sourceMap.begin(); itr != m_sourceMap.end(); ++itr) {
225 for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
226 if ((m_suppress && itr->second.msg[ic] >= abs(m_msgLimit[ic]) && m_msgLimit[ic] != 0) ||
227 (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value())) {
228 os << " ";
229 os.width(28);
230 os.setf(std::ios_base::left, std::ios_base::adjustfield);
231 os << itr->first;
232 os << "|";
233
234 os.width(8);
235 os.setf(std::ios_base::right, std::ios_base::adjustfield);
236 os << levelNames[ic];
237 os << " |";
238
239 os.width(9);
240 os << itr->second.msg[ic];
241 os << std::endl;
242
243 found = true;
244 }
245 }
246 }
247 os << "=====================================================" << std::endl;
248 if (found || m_stats) {
249 reportMessage(name(), MSG::INFO, os.str());
250 }
251
252 return StatusCode::SUCCESS;
253}
std::map< std::string, MsgAry > m_sourceMap
counts per source
Gaudi::Property< bool > m_stats
Gaudi::Property< unsigned int > m_statLevel
Gaudi::Property< bool > m_suppress

◆ getLogColor()

virtual std::string TrigMessageSvc::getLogColor ( int ) const
inlineoverridevirtual

Definition at line 90 of file TrigMessageSvc.h.

90{ return ""; }

◆ handle()

void TrigMessageSvc::handle ( const Incident & incident)
overridevirtual

Definition at line 104 of file TrigMessageSvc.cxx.

105{
106 if (incident.type() == AthenaInterprocess::UpdateAfterFork::type()) {
107 reportMessage(name(), MSG::INFO, "Enabling asynchronous message reporting");
108 m_thread = std::thread( &TrigMessageSvc::asyncReporting, this);
109 }
110}
static const std::string & type()
Incident type.
Definition Incidents.h:49
std::thread m_thread
Thread for asynchronous reporting.

◆ i_reportERS()

void TrigMessageSvc::i_reportERS ( const Message & msg) const
private

Report message to online messaging system (ERS).

Definition at line 374 of file TrigMessageSvc.cxx.

375{
376 /*
377 * Create ERS context object
378 *
379 * The (cross-node) MRS throttling is based on filename+line_number, i.e.
380 * ignoring the message text itself. We therefor use the message source as
381 * filename and the message hash as line_number. That way the same message
382 * from different nodes gets properly throttled by MRS.
383 */
384 const char* filename = msg.getSource().c_str();
385 const char* function_name = "";
386 const int line_number = msgHash(msg);
387 const char* package_name = "HLT";
388 ers::LocalContext hlt_context_info(package_name, filename, line_number, function_name);
389
390 // Create ERS issue object
391 Message m(msg);
392 if (m_eventIDLevel != MSG::NIL && msg.getType() >= static_cast<int>(m_eventIDLevel)) {
393 m.setFormat(m_ersFormat + " %E");
394 }
395 else {
396 m.setFormat(m_ersFormat);
397 }
398 std::ostringstream oss;
399 oss << m;
400 ers::HLTMessage ersMsg(hlt_context_info, oss.str());
401 ersMsg.add_qualifier("HLT"); // useful for filtering
402
403 // Forward Message to ERS
404 switch (msg.getType()) {
405 case MSG::NIL: break;
406 case MSG::VERBOSE: ers::debug(ersMsg, 2); break;
407 case MSG::DEBUG: ers::debug(ersMsg, 1); break;
408 case MSG::INFO: ers::info(ersMsg); break;
409 case MSG::WARNING: ers::warning(ersMsg); break;
410 case MSG::ERROR: ers::error(ersMsg); break;
411 case MSG::FATAL: ers::fatal(ersMsg); break;
412 default:
413 std::ostringstream oss;
414 oss << "Unknown message severity level: " << msg.getType() << " Original message was: " << m;
415 ers::error(ers::HLTMessage(ERS_HERE, oss.str()));
416 }
417}
Gaudi::Property< std::string > m_ersFormat
Gaudi::Property< unsigned int > m_eventIDLevel
static char * package_name
Definition cmdline.cxx:754
MsgStream & msg
Definition testRead.cxx:32

◆ i_reportMessage()

void TrigMessageSvc::i_reportMessage ( const Message & msg,
int outputLevel )
private

Internal implementation of reportMessage(const Message&,int) without lock.

Definition at line 282 of file TrigMessageSvc.cxx.

283{
284 const int key = msg.getType();
285 ++m_msgCount[key];
286
287 const Message* cmsg = &msg;
288 bool doPrint = true;
289 std::unique_ptr<Message> newMessage;
290
291 if (m_doSuppress || m_stats.value()) {
292
293 // Increase the counter of 'key' type of messages for the source and
294 // get the new value.
295 int nmsg = ++(m_sourceMap[msg.getSource()].msg[key]);
296
297 const int msgLimit = m_msgLimit[key].value();
298 if (m_doSuppress) {
299 if (msgLimit > 0) { // regular suppression
300 if (nmsg > msgLimit) doPrint = false;
301 if (nmsg == msgLimit) {
302 std::string txt = levelNames[key] + " message limit (" + std::to_string(msgLimit) +
303 ") reached for " + msg.getSource() + ". Suppressing further output.";
304 newMessage = std::make_unique<Message>(msg.getSource(), MSG::WARNING, std::move(txt));
305 cmsg = newMessage.get();
306 }
307 }
308 }
309 else if (msgLimit < 0) { // logarithmic suppression
310 // Calculate message hash
311 const unsigned int mh = msgHash(*cmsg);
312 // Check if we saw this message already and increase counter
313 auto m = m_msgHashCount.find(mh);
314 if (m != m_msgHashCount.end()) {
315 nmsg = ++m->second;
316 }
317 else {
318 nmsg = m_msgHashCount[mh] = 1;
319 }
320 if (nmsg == abs(msgLimit)) {
321 std::ostringstream os;
322 os << msg.getMessage() << " [Message limit (" << abs(msgLimit)
323 << ") reached. Log-suppression of further output.]";
324 newMessage = std::make_unique<Message>(msg.getSource(), msg.getType(), os.str());
325 cmsg = newMessage.get();
326 }
327 else if (nmsg > abs(msgLimit)) {
328 const int everyNth = (int)exp10((int)log10(nmsg));
329 if ((nmsg % everyNth) == 0) {
330 std::ostringstream os;
331 os << msg.getMessage() << " [suppressed " << everyNth << " similar messages]";
332 newMessage = std::make_unique<Message>(msg.getSource(), msg.getType(), os.str());
333 cmsg = newMessage.get();
334 }
335 }
336 }
337 }
338
339 // Print the message
340 if (doPrint && key >= outputLevel) {
341 if (m_eventIDLevel != MSG::NIL && key >= static_cast<int>(m_eventIDLevel)) {
342 cmsg->setFormat(m_defaultFormat + " %E");
343 }
344 else {
345 cmsg->setFormat(m_defaultFormat);
346 }
347 cmsg->setTimeFormat(m_defaultTimeFormat);
348 (*m_defaultStream) << *cmsg << std::endl << std::flush;
349
350 // ERS forwarding
351 if (passErsFilter(cmsg->getSource(), m_useERS[key]) && passErsLimit(*cmsg)) {
352 i_reportERS(*cmsg);
353 }
354 }
355
356 // Publish message statistics if enabled and only while RUNNING
357 if ( m_doPublish && key>=static_cast<int>(m_publishLevel) ) {
358 m_msgCountHist->Fill(key-m_publishLevel, 1);
359 if (m_msgCountSrcHist->GetYaxis()->FindFixBin(msg.getSource().c_str())<0) [[unlikely]] {
360 // Adding bins on the fly needs to be protected by mutex
361 oh_scoped_lock_histogram lock;
362 m_msgCountSrcHist->Fill(key-m_publishLevel, msg.getSource().c_str(), 1);
363 m_msgCountSrcHist->LabelsDeflate("Y");
364 }
365 else {
366 m_msgCountSrcHist->Fill(key-m_publishLevel, msg.getSource().c_str(), 1);
367 }
368 }
369}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
bool passErsFilter(const std::string &source, const std::vector< std::string > &filter) const
virtual int outputLevel() const override
bool passErsLimit(const Message &msg)
Gaudi::Property< std::string > m_defaultTimeFormat
std::map< size_t, unsigned int > m_msgHashCount
counts per message hash
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_useERS
Special properties to control output to ERS of individual sources.
void i_reportERS(const Message &msg) const
Report message to online messaging system (ERS).
Gaudi::Property< std::string > m_defaultFormat
bool m_doSuppress
is suppression currently enabled?
#define unlikely(x)

◆ initialize()

StatusCode TrigMessageSvc::initialize ( )
overridevirtual

Definition at line 52 of file TrigMessageSvc.cxx.

53{
54 StatusCode sc = Service::initialize();
55 if (sc.isFailure()) return sc;
56
57 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
58 sc = incSvc.retrieve();
59 if (sc.isFailure()) {
60 reportMessage(name(), MSG::WARNING, "Cannot find IncidentSvc");
61 }
62 else {
63 incSvc->addListener(this, AthenaInterprocess::UpdateAfterFork::type());
64 }
65
67
68 if (m_color) {
69 std::cout << "TrigMessageSvc WARNING: Colors are not supported by TrigMessageSvc" << std::endl;
70 }
71 return StatusCode::SUCCESS;
72}
static Double_t sc
Gaudi::Property< bool > m_color
Gaudi::Property< bool > m_suppressRunningOnly
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ insertMessage()

virtual void TrigMessageSvc::insertMessage ( const StatusCode & ,
Message  )
inlineoverridevirtual

Definition at line 95 of file TrigMessageSvc.h.

95{ NOTSUPPORTED; }

◆ insertStream()

virtual void TrigMessageSvc::insertStream ( int ,
std::string ,
std::ostream *  )
inlineoverridevirtual

Definition at line 99 of file TrigMessageSvc.h.

99{ NOTSUPPORTED; }

◆ messageCount()

int TrigMessageSvc::messageCount ( MSG::Level logLevel) const
overridevirtual

Definition at line 459 of file TrigMessageSvc.cxx.

◆ outputLevel() [1/2]

int TrigMessageSvc::outputLevel ( ) const
overridevirtual

Definition at line 429 of file TrigMessageSvc.cxx.

430{
431 return m_outputLevel;
432}

◆ outputLevel() [2/2]

int TrigMessageSvc::outputLevel ( std::string_view source) const
overridevirtual

Definition at line 434 of file TrigMessageSvc.cxx.

435{
436 std::unique_lock<std::recursive_mutex> lock(m_thresholdMapMutex);
437 auto it = m_thresholdMap.find(source);
438 return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
439}
std::recursive_mutex m_thresholdMapMutex
ThresholdMap m_thresholdMap
Output level threshold map.

◆ passErsFilter()

bool TrigMessageSvc::passErsFilter ( const std::string & source,
const std::vector< std::string > & filter ) const
private

Definition at line 464 of file TrigMessageSvc.cxx.

466{
467 if (filter.empty()) return false; // forward none
468 auto it = filter.begin();
469 if (filter.size() == 1 && (*it) == "*") return true; // forward all
470
471 bool pass(false);
472 for (; it != filter.end(); ++it) {
473 if ((*it) == "*") pass = true; // forward except if there is a veto later
474 if (source == (*it)) return true; // forward specific source
475 if ("!" + source == (*it)) return false; // veto specific source
476 }
477 return pass;
478}

◆ passErsLimit()

bool TrigMessageSvc::passErsLimit ( const Message & msg)
private

Definition at line 480 of file TrigMessageSvc.cxx.

481{
482 if (m_ersEventLimit < 0) return true;
483
484 const EventContext::ContextID_t slot = msg.getEventSlot();
485 const EventContext::ContextEvt_t evt = msg.getEventNumber();
486 // get or create message statistics for this slot
487 auto [itr, inserted] = m_slotMsgCount.insert( {slot, {evt, MsgAry()} } );
488
489 // if new event in slot then reset counters
490 if ( itr->second.first != evt ) {
491 itr->second = {evt, MsgAry()};
492 }
493
494 // increment number of messages for this level and slot
495 const int N = ++itr->second.second.msg[msg.getType()];
496
497 return N <= m_ersEventLimit;
498}
std::unordered_map< EventContext::ContextID_t, std::pair< EventContext::ContextEvt_t, MsgAry > > m_slotMsgCount
counts per slot and level
Gaudi::Property< int > m_ersEventLimit
constexpr std::size_t N
Private helper class to keep the count of messages of a type (MSG::LEVEL).

◆ reinitialize()

StatusCode TrigMessageSvc::reinitialize ( )
overridevirtual

Definition at line 74 of file TrigMessageSvc.cxx.

75{
76 m_state = Gaudi::StateMachine::OFFLINE;
78 if ( sc.isSuccess() ) m_state = Gaudi::StateMachine::INITIALIZED;
79 return sc;
80}
virtual StatusCode initialize() override

◆ reportMessage() [1/4]

void TrigMessageSvc::reportMessage ( const Message & message)
overridevirtual

Definition at line 419 of file TrigMessageSvc.cxx.

420{
421 reportMessage(msg, outputLevel(msg.getSource()));
422}

◆ reportMessage() [2/4]

void TrigMessageSvc::reportMessage ( const Message & msg,
int outputLevel )
overridevirtual

Definition at line 255 of file TrigMessageSvc.cxx.

256{
257 if (m_asyncReporting) {
258 // msg has to be copied as the reference may become invalid by the time it is used
259 //coverity[PASS_BY_VALUE]
260 m_messageActionsQueue.emplace([this, m=Message(msg), outputLevel]() {
261 this->i_reportMessage(m, outputLevel); });
262 }
263 else {
265 }
266}
void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.

◆ reportMessage() [3/4]

virtual void TrigMessageSvc::reportMessage ( const StatusCode & ,
std::string_view  )
inlineoverridevirtual

Not supported by this implementation.

Definition at line 93 of file TrigMessageSvc.h.

93{ NOTSUPPORTED; }

◆ reportMessage() [4/4]

void TrigMessageSvc::reportMessage ( std::string source,
int type,
std::string message )
overridevirtual

Definition at line 424 of file TrigMessageSvc.cxx.

425{
426 reportMessage(Message{std::move(source), type, std::move(message)});
427}

◆ setDefaultStream()

virtual void TrigMessageSvc::setDefaultStream ( std::ostream * stream)
inlineoverridevirtual

Definition at line 78 of file TrigMessageSvc.h.

◆ setOutputLevel() [1/2]

void TrigMessageSvc::setOutputLevel ( int new_level)
overridevirtual

Definition at line 441 of file TrigMessageSvc.cxx.

442{
443 m_outputLevel = new_level;
444}

◆ setOutputLevel() [2/2]

void TrigMessageSvc::setOutputLevel ( std::string_view source,
int new_level )
overridevirtual

Definition at line 446 of file TrigMessageSvc.cxx.

447{
448 std::unique_lock<std::recursive_mutex> lock(m_thresholdMapMutex);
449
450 // only write if we really have to...
451 auto i = m_thresholdMap.find( source );
452 if ( i == m_thresholdMap.end() ) {
453 m_thresholdMap.emplace( source, level );
454 } else if ( i->second != level ) {
455 i->second = level;
456 }
457}

◆ setupLimits()

void TrigMessageSvc::setupLimits ( Gaudi::Details::PropertyBase & prop)
private

Definition at line 145 of file TrigMessageSvc.cxx.

146{
147 // Just report problems in the settings of the limits and unknown limit
148 // parameters
149 if (prop.name() == "alwaysLimit") {
150 Gaudi::Property<int>* p = dynamic_cast<Gaudi::Property<int>*>(&prop);
151 if (p && p->value() != 0) {
152 std::cout << "TrigMessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
153 p->setValue(0);
154 }
155 }
156 else if (prop.name() == "defaultLimit") {
157 for (int i = MSG::VERBOSE; i < MSG::NUM_LEVELS; ++i) {
158 if (i != MSG::ALWAYS) {
159 m_msgLimit[i] = m_msgLimit[MSG::NIL].value();
160 }
161 }
162 }
163 else if (prop.name() != "fatalLimit" && prop.name() != "errorLimit" &&
164 prop.name() != "warningLimit" && prop.name() == "infoLimit" &&
165 prop.name() == "debugLimit" && prop.name() == "verboseLimit") {
166 std::cout << "TrigMessageSvc ERROR: Unknown message limit parameter: " << prop.name()
167 << std::endl;
168 return;
169 }
170}

◆ setupThreshold()

void TrigMessageSvc::setupThreshold ( Gaudi::Details::PropertyBase & prop)
private

Definition at line 172 of file TrigMessageSvc.cxx.

173{
174 static const std::array<std::pair<const char*, MSG::Level>, 7> tbl{{{"setFatal", MSG::FATAL},
175 {"setError", MSG::ERROR},
176 {"setWarning", MSG::WARNING},
177 {"setInfo", MSG::INFO},
178 {"setDebug", MSG::DEBUG},
179 {"setVerbose", MSG::VERBOSE},
180 {"setAlways", MSG::ALWAYS}}};
181
182 auto i = std::find_if(
183 std::begin(tbl), std::end(tbl),
184 [&](const std::pair<const char*, MSG::Level>& t) { return prop.name() == t.first; });
185 if (i == std::end(tbl)) {
186 std::cerr << "TrigMessageSvc ERROR: Unknown message threshold parameter: " << prop.name()
187 << std::endl;
188 return;
189 }
190 int ic = i->second;
191
192 Gaudi::Property<std::vector<std::string>>* sap =
193 dynamic_cast<Gaudi::Property<std::vector<std::string>>*>(&prop);
194 if (!sap) {
195 std::cerr << "could not dcast " << prop.name()
196 << " to a Gaudi::Property<std::vector<std::string>> (which it "
197 "should be!)"
198 << std::endl;
199 }
200 else {
201 for (auto& i : sap->value()) setOutputLevel(i, ic);
202 }
203}
virtual void setOutputLevel(int new_level) override

◆ start()

StatusCode TrigMessageSvc::start ( )
overridevirtual

Definition at line 82 of file TrigMessageSvc.cxx.

83{
85 m_doPublish = true;
87 return StatusCode::SUCCESS;
88}

◆ stop()

StatusCode TrigMessageSvc::stop ( )
overridevirtual

Definition at line 90 of file TrigMessageSvc.cxx.

91{
92 // Disable asynchronous reporting again
93 if (m_asyncReporting) {
94 m_messageActionsQueue.emplace( [this]() {m_asyncReporting = false;} );
95 reportMessage(name(), MSG::INFO, "Disabling asynchronous message reporting");
96 m_thread.join();
97 }
98
99 m_doPublish = false;
101 return StatusCode::SUCCESS;
102}

◆ useColor()

virtual bool TrigMessageSvc::useColor ( ) const
inlineoverridevirtual

Definition at line 89 of file TrigMessageSvc.h.

89{ return m_color; }

Member Data Documentation

◆ m_asyncReporting

bool TrigMessageSvc::m_asyncReporting {false}
private

(

See also
MsgStream::doOutput). Async reporting active

Definition at line 198 of file TrigMessageSvc.h.

198{false};

◆ m_color

Gaudi::Property<bool> TrigMessageSvc::m_color
private
Initial value:
{this, "useColors", false,
"Colors are not supported by TrigMessageSvc"}

Definition at line 123 of file TrigMessageSvc.h.

123 {this, "useColors", false,
124 "Colors are not supported by TrigMessageSvc"};

◆ m_defaultFormat

Gaudi::Property<std::string> TrigMessageSvc::m_defaultFormat
private
Initial value:
{this, "Format", Message::getDefaultFormat(),
"Default message format"}

Definition at line 110 of file TrigMessageSvc.h.

110 {this, "Format", Message::getDefaultFormat(),
111 "Default message format"};

◆ m_defaultStream

std::ostream* TrigMessageSvc::m_defaultStream = &std::cout
private

Pointer to the output stream.

Definition at line 173 of file TrigMessageSvc.h.

◆ m_defaultTimeFormat

Gaudi::Property<std::string> TrigMessageSvc::m_defaultTimeFormat
private
Initial value:
{
this, "timeFormat", Message::getDefaultTimeFormat(), "Message time format"}

Definition at line 114 of file TrigMessageSvc.h.

114 {
115 this, "timeFormat", Message::getDefaultTimeFormat(), "Message time format"};

◆ m_doPublish

bool TrigMessageSvc::m_doPublish {false}
private

are we publishing message statistics?

Definition at line 190 of file TrigMessageSvc.h.

190{false};

◆ m_doSuppress

bool TrigMessageSvc::m_doSuppress {false}
private

is suppression currently enabled?

Definition at line 191 of file TrigMessageSvc.h.

191{false};

◆ m_ersEventLimit

Gaudi::Property<int> TrigMessageSvc::m_ersEventLimit
private
Initial value:
{this, "ersPerEventLimit", -1,
"Maximum number of messages (per event and level) that are forwarded to ERS (-1: disabled)"}

Definition at line 167 of file TrigMessageSvc.h.

167 {this, "ersPerEventLimit", -1,
168 "Maximum number of messages (per event and level) that are forwarded to ERS (-1: disabled)"};

◆ m_ersFormat

Gaudi::Property<std::string> TrigMessageSvc::m_ersFormat
private
Initial value:
{this, "ErsFormat", Message::getDefaultFormat(),
"ERS message format"}

Definition at line 112 of file TrigMessageSvc.h.

112 {this, "ErsFormat", Message::getDefaultFormat(),
113 "ERS message format"};

◆ m_eventIDLevel

Gaudi::Property<unsigned int> TrigMessageSvc::m_eventIDLevel
private
Initial value:
{this, "printEventIDLevel", MSG::NIL,
"Print event ID for this and higher message levels"}

Definition at line 121 of file TrigMessageSvc.h.

121 {this, "printEventIDLevel", MSG::NIL,
122 "Print event ID for this and higher message levels"};

◆ m_messageActionsQueue

tbb::concurrent_bounded_queue<std::function<void()> > TrigMessageSvc::m_messageActionsQueue
private

Definition at line 200 of file TrigMessageSvc.h.

◆ m_msgCount

std::array<int, MSG::NUM_LEVELS> TrigMessageSvc::m_msgCount {}
private

counts per level

Definition at line 185 of file TrigMessageSvc.h.

185{};

◆ m_msgCountHist

TH1I* TrigMessageSvc::m_msgCountHist {nullptr}
private

Message counting per level histogram.

Definition at line 193 of file TrigMessageSvc.h.

193{nullptr};

◆ m_msgCountSrcHist

TH2I* TrigMessageSvc::m_msgCountSrcHist {nullptr}
private

Message counting per message source.

Definition at line 194 of file TrigMessageSvc.h.

194{nullptr};

◆ m_msgHashCount

std::map<size_t, unsigned int> TrigMessageSvc::m_msgHashCount
private

counts per message hash

Definition at line 186 of file TrigMessageSvc.h.

◆ m_msgLimit

std::array<Gaudi::Property<int>, MSG::NUM_LEVELS> TrigMessageSvc::m_msgLimit
private
Initial value:
{{{this, "defaultLimit", 500},
{this, "verboseLimit", 500},
{this, "debugLimit", 500},
{this, "infoLimit", 500},
{this, "warningLimit", 500},
{this, "errorLimit", 500},
{this, "fatalLimit", 500},
{this, "alwaysLimit", 0}}}

Definition at line 139 of file TrigMessageSvc.h.

139 {{{this, "defaultLimit", 500},
140 {this, "verboseLimit", 500},
141 {this, "debugLimit", 500},
142 {this, "infoLimit", 500},
143 {this, "warningLimit", 500},
144 {this, "errorLimit", 500},
145 {this, "fatalLimit", 500},
146 {this, "alwaysLimit", 0}}};

◆ m_publishLevel

Gaudi::Property<unsigned int> TrigMessageSvc::m_publishLevel
private
Initial value:
{this, "publishLevel", MSG::INFO,
"Publish message statistics for this and higher message levels"}

Definition at line 119 of file TrigMessageSvc.h.

119 {this, "publishLevel", MSG::INFO,
120 "Publish message statistics for this and higher message levels"};

◆ m_slotMsgCount

std::unordered_map<EventContext::ContextID_t, std::pair<EventContext::ContextEvt_t, MsgAry> > TrigMessageSvc::m_slotMsgCount
private

counts per slot and level

Definition at line 188 of file TrigMessageSvc.h.

◆ m_sourceMap

std::map<std::string, MsgAry> TrigMessageSvc::m_sourceMap
private

counts per source

Definition at line 184 of file TrigMessageSvc.h.

◆ m_statLevel

Gaudi::Property<unsigned int> TrigMessageSvc::m_statLevel
private
Initial value:
{this, "statLevel", 0,
"Show total message statistics for >= level"}

Definition at line 117 of file TrigMessageSvc.h.

117 {this, "statLevel", 0,
118 "Show total message statistics for >= level"};

◆ m_stats

Gaudi::Property<bool> TrigMessageSvc::m_stats {this, "showStats", false, "Show message statistics"}
private

Definition at line 116 of file TrigMessageSvc.h.

116{this, "showStats", false, "Show message statistics"};

◆ m_suppress

Gaudi::Property<bool> TrigMessageSvc::m_suppress {this, "enableSuppression", false, "Enable message suppression"}
private

Definition at line 125 of file TrigMessageSvc.h.

125{this, "enableSuppression", false, "Enable message suppression"};

◆ m_suppressRunningOnly

Gaudi::Property<bool> TrigMessageSvc::m_suppressRunningOnly
private
Initial value:
{this, "suppressRunningOnly", true,
"Use message suppression only during RUNNING state"}

Definition at line 126 of file TrigMessageSvc.h.

126 {this, "suppressRunningOnly", true,
127 "Use message suppression only during RUNNING state"};

◆ m_thread

std::thread TrigMessageSvc::m_thread
private

Thread for asynchronous reporting.

Definition at line 199 of file TrigMessageSvc.h.

◆ m_thresholdMap

ThresholdMap TrigMessageSvc::m_thresholdMap
private

Output level threshold map.

Definition at line 174 of file TrigMessageSvc.h.

◆ m_thresholdMapMutex

std::recursive_mutex TrigMessageSvc::m_thresholdMapMutex
mutableprivate

Definition at line 196 of file TrigMessageSvc.h.

◆ m_thresholdProp

std::array<Gaudi::Property<std::vector<std::string> >, MSG::NUM_LEVELS> TrigMessageSvc::m_thresholdProp
private
Initial value:
{
{{},
{this, "setVerbose"},
{this, "setDebug"},
{this, "setInfo"},
{this, "setWarning"},
{this, "setError"},
{this, "setFatal"},
{this, "setAlways"}}}

Definition at line 129 of file TrigMessageSvc.h.

129 {
130 {{/*ignored*/},
131 {this, "setVerbose"},
132 {this, "setDebug"},
133 {this, "setInfo"},
134 {this, "setWarning"},
135 {this, "setError"},
136 {this, "setFatal"},
137 {this, "setAlways"}}};

◆ m_useERS

std::array<Gaudi::Property<std::vector<std::string> >, MSG::NUM_LEVELS> TrigMessageSvc::m_useERS
private
Initial value:
{
{{},
{this, "useErsVerbose", {}},
{this, "useErsDebug", {}},
{this, "useErsInfo", {}},
{this, "useErsWarning", {}},
{this, "useErsError", {}},
{this, "useErsFatal", {}},
{this, "useErsAlways", {}}}}

Special properties to control output to ERS of individual sources.

The syntax is as follows (these are NOT regular expressions):

useErsFatal = [] # forward none (default) useErsFatal = [''] # forward all useErsFatal = ['CoreDumpSvc','MyAlg'] # forward these sources useErsFatal = ['','!MyAlg'] # forward all except MyAlg

Definition at line 157 of file TrigMessageSvc.h.

157 {
158 {{/*ignored*/},
159 {this, "useErsVerbose", {}},
160 {this, "useErsDebug", {}},
161 {this, "useErsInfo", {}},
162 {this, "useErsWarning", {}},
163 {this, "useErsError", {}},
164 {this, "useErsFatal", {}},
165 {this, "useErsAlways", {}}}};

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