ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrigMessageSvc Class Reference

MessageSvc used by the HLT applications. More...

#include <TrigMessageSvc.h>

Inheritance diagram for TrigMessageSvc:
Collaboration 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. More...
 
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. More...
 
void i_reportERS (const Message &msg) const
 Report message to online messaging system (ERS) More...
 
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. More...
 
Gaudi::Property< int > m_ersEventLimit
 
std::ostream * m_defaultStream = &std::cout
 Pointer to the output stream. More...
 
ThresholdMap m_thresholdMap
 Output level threshold map. More...
 
std::map< std::string, MsgArym_sourceMap
 counts per source More...
 
std::array< int, MSG::NUM_LEVELS > m_msgCount {}
 counts per level More...
 
std::map< size_t, unsigned int > m_msgHashCount
 counts per message hash More...
 
std::unordered_map< EventContext::ContextID_t, std::pair< EventContext::ContextEvt_t, MsgAry > > m_slotMsgCount
 counts per slot and level More...
 
bool m_doPublish {false}
 are we publishing message statistics? More...
 
bool m_doSuppress {false}
 is suppression currently enabled? More...
 
TH1Im_msgCountHist {nullptr}
 Message counting per level histogram. More...
 
TH2Im_msgCountSrcHist {nullptr}
 Message counting per message source. More...
 
std::recursive_mutex m_thresholdMapMutex
 
bool m_asyncReporting {false}
 ( More...
 
std::thread m_thread
 Thread for asynchronous reporting. More...
 
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 56 of file TrigMessageSvc.h.

Member Typedef Documentation

◆ ThresholdMap

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

Definition at line 58 of file TrigMessageSvc.h.

Constructor & Destructor Documentation

◆ TrigMessageSvc()

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

Definition at line 38 of file TrigMessageSvc.cxx.

38  :
39  base_class(name, svcloc)
40 {
41  m_outputLevel.declareUpdateHandler([svcloc](Gaudi::Details::PropertyBase&) {
42  SmartIF<IAppMgrUI> app = svcloc;
43  if (app) app->outputLevelUpdate();
44  });
45 
46  for (int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
47  m_msgLimit[ic].declareUpdateHandler(&TrigMessageSvc::setupLimits, this);
48  m_thresholdProp[ic].declareUpdateHandler(&TrigMessageSvc::setupThreshold, this);
49  }
50 
52 }

Member Function Documentation

◆ asyncReporting()

void TrigMessageSvc::asyncReporting ( )
private

Definition at line 269 of file TrigMessageSvc.cxx.

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

◆ ATLAS_NOT_CONST_THREAD_SAFE()

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

Definition at line 72 of file TrigMessageSvc.h.

73  {
74  return m_defaultStream;
75  }

◆ bookHistograms()

void TrigMessageSvc::bookHistograms ( )
private

Definition at line 114 of file TrigMessageSvc.cxx.

115 {
116  ServiceHandle<ITHistSvc> histSvc("THistSvc", name());
117  if ( histSvc.retrieve().isFailure() ) {
118  reportMessage(name(), MSG::WARNING, "Cannot find THistSvc. Message stats will not be published.");
119  m_doPublish = false;
120  return;
121  }
122 
123  // monitoring information root directory
124  const std::string path = "/EXPERT/HLTFramework/" + name() + "/";
125  const int nLevelBins = MSG::NUM_LEVELS - m_publishLevel;
126  m_msgCountHist = new TH1I("MessageCount", "Messages while RUNNING;Severity;Count",
127  nLevelBins, 0, nLevelBins);
128 
129  const int nSrcBins = 1;
130  m_msgCountSrcHist = new TH2I("MessageCountBySource", "Messages while RUNNING;Severity;Source",
131  nLevelBins, 0, nLevelBins, nSrcBins, 0, nSrcBins);
132 
133  for (int i=m_publishLevel; i<MSG::NUM_LEVELS; i++) {
134  m_msgCountHist->GetXaxis()->SetBinLabel(i-m_publishLevel+1, levelNames[i].c_str());
135  m_msgCountSrcHist->GetXaxis()->SetBinLabel(i-m_publishLevel+1, levelNames[i].c_str());
136  }
137 
138  if ( histSvc->regHist(path + m_msgCountHist->GetName(), m_msgCountHist).isFailure() ) {
139  reportMessage(name(), MSG::WARNING, "Cannot register monitoring histogram 'MessageCount'");
140  }
141  if ( histSvc->regHist(path + m_msgCountSrcHist->GetName(), m_msgCountSrcHist).isFailure() ) {
142  reportMessage(name(), MSG::WARNING, "Cannot register monitoring histogram 'MessageCountBySource'");
143  }
144 }

◆ eraseMessage() [1/3]

virtual void TrigMessageSvc::eraseMessage ( )
inlineoverridevirtual

Definition at line 94 of file TrigMessageSvc.h.

94 { NOTSUPPORTED; }

◆ eraseMessage() [2/3]

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

Definition at line 95 of file TrigMessageSvc.h.

95 { NOTSUPPORTED; }

◆ eraseMessage() [3/3]

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

Definition at line 96 of file TrigMessageSvc.h.

96 { NOTSUPPORTED; }

◆ eraseStream() [1/4]

virtual void TrigMessageSvc::eraseStream ( )
inlineoverridevirtual

Definition at line 98 of file TrigMessageSvc.h.

98 { NOTSUPPORTED; }

◆ eraseStream() [2/4]

virtual void TrigMessageSvc::eraseStream ( int  )
inlineoverridevirtual

Definition at line 99 of file TrigMessageSvc.h.

99 { NOTSUPPORTED; }

◆ eraseStream() [3/4]

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

Definition at line 100 of file TrigMessageSvc.h.

100 { NOTSUPPORTED; }

◆ eraseStream() [4/4]

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

Definition at line 101 of file TrigMessageSvc.h.

101 { NOTSUPPORTED; }

◆ finalize()

StatusCode TrigMessageSvc::finalize ( )
overridevirtual

Definition at line 207 of file TrigMessageSvc.cxx.

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

◆ getLogColor()

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

Definition at line 89 of file TrigMessageSvc.h.

89 { return ""; }

◆ handle()

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

Definition at line 106 of file TrigMessageSvc.cxx.

107 {
108  if (incident.type() == AthenaInterprocess::UpdateAfterFork::type()) {
109  reportMessage(name(), MSG::INFO, "Enabling asynchronous message reporting");
110  m_thread = std::thread( &TrigMessageSvc::asyncReporting, this);
111  }
112 }

◆ i_reportERS()

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

Report message to online messaging system (ERS)

Definition at line 375 of file TrigMessageSvc.cxx.

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

◆ i_reportMessage()

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

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

Definition at line 283 of file TrigMessageSvc.cxx.

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

◆ initialize()

StatusCode TrigMessageSvc::initialize ( )
overridevirtual

Definition at line 54 of file TrigMessageSvc.cxx.

55 {
57  if (sc.isFailure()) return sc;
58 
59  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
60  sc = incSvc.retrieve();
61  if (sc.isFailure()) {
62  reportMessage(name(), MSG::WARNING, "Cannot find IncidentSvc");
63  }
64  else {
65  incSvc->addListener(this, AthenaInterprocess::UpdateAfterFork::type());
66  }
67 
69 
70  if (m_color) {
71  std::cout << "TrigMessageSvc WARNING: Colors are not supported by TrigMessageSvc" << std::endl;
72  }
73  return StatusCode::SUCCESS;
74 }

◆ insertMessage()

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

Definition at line 93 of file TrigMessageSvc.h.

93 { NOTSUPPORTED; }

◆ insertStream()

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

Definition at line 97 of file TrigMessageSvc.h.

97 { NOTSUPPORTED; }

◆ messageCount()

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

Definition at line 460 of file TrigMessageSvc.cxx.

461 {
462  return m_msgCount[level];
463 }

◆ outputLevel() [1/2]

int TrigMessageSvc::outputLevel ( ) const
overridevirtual

Definition at line 430 of file TrigMessageSvc.cxx.

431 {
432  return m_outputLevel;
433 }

◆ outputLevel() [2/2]

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

Definition at line 435 of file TrigMessageSvc.cxx.

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

◆ passErsFilter()

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

Definition at line 465 of file TrigMessageSvc.cxx.

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

◆ passErsLimit()

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

Definition at line 481 of file TrigMessageSvc.cxx.

482 {
483  if (m_ersEventLimit < 0) return true;
484 
485  const EventContext::ContextID_t slot = msg.getEventSlot();
486  const EventContext::ContextEvt_t evt = msg.getEventNumber();
487  // get or create message statistics for this slot
488  auto [itr, inserted] = m_slotMsgCount.insert( {slot, {evt, MsgAry()} } );
489 
490  // if new event in slot then reset counters
491  if ( itr->second.first != evt ) {
492  itr->second = {evt, MsgAry()};
493  }
494 
495  // increment number of messages for this level and slot
496  const int N = ++itr->second.second.msg[msg.getType()];
497 
498  return N <= m_ersEventLimit;
499 }

◆ reinitialize()

StatusCode TrigMessageSvc::reinitialize ( )
overridevirtual

Definition at line 76 of file TrigMessageSvc.cxx.

77 {
78  m_state = Gaudi::StateMachine::OFFLINE;
80  if ( sc.isSuccess() ) m_state = Gaudi::StateMachine::INITIALIZED;
81  return sc;
82 }

◆ reportMessage() [1/4]

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

Definition at line 420 of file TrigMessageSvc.cxx.

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

◆ reportMessage() [2/4]

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

Definition at line 257 of file TrigMessageSvc.cxx.

258 {
259  if (m_asyncReporting) {
260  // msg has to be copied as the reference may become invalid by the time it is used
261  m_messageActionsQueue.emplace([this, m=Message(msg), outputLevel]() {
262  this->i_reportMessage(m, outputLevel); });
263  }
264  else {
266  }
267 }

◆ reportMessage() [3/4]

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

Not supported by this implementation.

Definition at line 92 of file TrigMessageSvc.h.

92 { NOTSUPPORTED; }

◆ reportMessage() [4/4]

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

Definition at line 425 of file TrigMessageSvc.cxx.

426 {
428 }

◆ setDefaultStream()

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

Definition at line 77 of file TrigMessageSvc.h.

78  {
80  }

◆ setOutputLevel() [1/2]

void TrigMessageSvc::setOutputLevel ( int  new_level)
overridevirtual

Definition at line 442 of file TrigMessageSvc.cxx.

443 {
444  m_outputLevel = new_level;
445 }

◆ setOutputLevel() [2/2]

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

Definition at line 447 of file TrigMessageSvc.cxx.

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

◆ setupLimits()

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

Definition at line 147 of file TrigMessageSvc.cxx.

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

◆ setupThreshold()

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

Definition at line 174 of file TrigMessageSvc.cxx.

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

◆ start()

StatusCode TrigMessageSvc::start ( )
overridevirtual

Definition at line 84 of file TrigMessageSvc.cxx.

85 {
87  m_doPublish = true;
89  return StatusCode::SUCCESS;
90 }

◆ stop()

StatusCode TrigMessageSvc::stop ( )
overridevirtual

Definition at line 92 of file TrigMessageSvc.cxx.

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

◆ useColor()

virtual bool TrigMessageSvc::useColor ( ) const
inlineoverridevirtual

Definition at line 88 of file TrigMessageSvc.h.

88 { return m_color; }

Member Data Documentation

◆ m_asyncReporting

bool TrigMessageSvc::m_asyncReporting {false}
private

(

See also
MsgStream::doOutput). Async reporting active

Definition at line 196 of file TrigMessageSvc.h.

◆ m_color

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

Definition at line 121 of file TrigMessageSvc.h.

◆ m_defaultFormat

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

Definition at line 108 of file TrigMessageSvc.h.

◆ m_defaultStream

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

Pointer to the output stream.

Definition at line 171 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 112 of file TrigMessageSvc.h.

◆ m_doPublish

bool TrigMessageSvc::m_doPublish {false}
private

are we publishing message statistics?

Definition at line 188 of file TrigMessageSvc.h.

◆ m_doSuppress

bool TrigMessageSvc::m_doSuppress {false}
private

is suppression currently enabled?

Definition at line 189 of file TrigMessageSvc.h.

◆ 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 165 of file TrigMessageSvc.h.

◆ m_ersFormat

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

Definition at line 110 of file TrigMessageSvc.h.

◆ 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 119 of file TrigMessageSvc.h.

◆ m_messageActionsQueue

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

Definition at line 198 of file TrigMessageSvc.h.

◆ m_msgCount

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

counts per level

Definition at line 183 of file TrigMessageSvc.h.

◆ m_msgCountHist

TH1I* TrigMessageSvc::m_msgCountHist {nullptr}
private

Message counting per level histogram.

Definition at line 191 of file TrigMessageSvc.h.

◆ m_msgCountSrcHist

TH2I* TrigMessageSvc::m_msgCountSrcHist {nullptr}
private

Message counting per message source.

Definition at line 192 of file TrigMessageSvc.h.

◆ m_msgHashCount

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

counts per message hash

Definition at line 184 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 137 of file TrigMessageSvc.h.

◆ 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 117 of file TrigMessageSvc.h.

◆ 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 186 of file TrigMessageSvc.h.

◆ m_sourceMap

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

counts per source

Definition at line 182 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 115 of file TrigMessageSvc.h.

◆ m_stats

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

Definition at line 114 of file TrigMessageSvc.h.

◆ m_suppress

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

Definition at line 123 of file TrigMessageSvc.h.

◆ m_suppressRunningOnly

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

Definition at line 124 of file TrigMessageSvc.h.

◆ m_thread

std::thread TrigMessageSvc::m_thread
private

Thread for asynchronous reporting.

Definition at line 197 of file TrigMessageSvc.h.

◆ m_thresholdMap

ThresholdMap TrigMessageSvc::m_thresholdMap
private

Output level threshold map.

Definition at line 172 of file TrigMessageSvc.h.

◆ m_thresholdMapMutex

std::recursive_mutex TrigMessageSvc::m_thresholdMapMutex
mutableprivate

Definition at line 194 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 127 of file TrigMessageSvc.h.

◆ 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 155 of file TrigMessageSvc.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
NOTSUPPORTED
#define NOTSUPPORTED
Definition: TrigMessageSvc.h:31
TrigMessageSvc::setupThreshold
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Definition: TrigMessageSvc.cxx:174
TrigMessageSvc::m_messageActionsQueue
tbb::concurrent_bounded_queue< std::function< void()> > m_messageActionsQueue
Definition: TrigMessageSvc.h:198
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
TrigMessageSvc::m_defaultFormat
Gaudi::Property< std::string > m_defaultFormat
Definition: TrigMessageSvc.h:108
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:173
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigMessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: TrigMessageSvc.h:172
TH1I
Definition: rootspy.cxx:332
TrigMessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
counts per level
Definition: TrigMessageSvc.h:183
initialize
void initialize()
Definition: run_EoverP.cxx:894
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TrigMessageSvc::m_msgCountHist
TH1I * m_msgCountHist
Message counting per level histogram.
Definition: TrigMessageSvc.h:191
TrigMessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: TrigMessageSvc.h:137
TrigMessageSvc::m_ersFormat
Gaudi::Property< std::string > m_ersFormat
Definition: TrigMessageSvc.h:110
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ReweightUtils.message
message
Definition: ReweightUtils.py:15
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
TrigMessageSvc::m_thresholdMapMutex
std::recursive_mutex m_thresholdMapMutex
Definition: TrigMessageSvc.h:194
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrigMessageSvc::asyncReporting
void asyncReporting()
Definition: TrigMessageSvc.cxx:269
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
oh_scoped_lock_histogram
Scoped lock to be used for threaded histogram operations.
Definition: OHLockedHist.h:108
covarianceTool.filter
filter
Definition: covarianceTool.py:514
TrigMessageSvc::initialize
virtual StatusCode initialize() override
Definition: TrigMessageSvc.cxx:54
TrigMessageSvc::outputLevel
virtual int outputLevel() const override
Definition: TrigMessageSvc.cxx:430
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
TrigMessageSvc::m_ersEventLimit
Gaudi::Property< int > m_ersEventLimit
Definition: TrigMessageSvc.h:165
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigMessageSvc::m_doPublish
bool m_doPublish
are we publishing message statistics?
Definition: TrigMessageSvc.h:188
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TH2I
Definition: rootspy.cxx:410
TrigMessageSvc::m_sourceMap
std::map< std::string, MsgAry > m_sourceMap
counts per source
Definition: TrigMessageSvc.h:182
TrigMessageSvc::m_msgCountSrcHist
TH2I * m_msgCountSrcHist
Message counting per message source.
Definition: TrigMessageSvc.h:192
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
TrigMessageSvc::setOutputLevel
virtual void setOutputLevel(int new_level) override
Definition: TrigMessageSvc.cxx:442
TrigMessageSvc::m_thresholdProp
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
Definition: TrigMessageSvc.h:127
TrigMessageSvc::reportMessage
virtual void reportMessage(const Message &message) override
Definition: TrigMessageSvc.cxx:420
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TrigMessageSvc::m_eventIDLevel
Gaudi::Property< unsigned int > m_eventIDLevel
Definition: TrigMessageSvc.h:119
TrigMessageSvc::passErsFilter
bool passErsFilter(const std::string &source, const std::vector< std::string > &filter) const
Definition: TrigMessageSvc.cxx:465
TrigMessageSvc::passErsLimit
bool passErsLimit(const Message &msg)
Definition: TrigMessageSvc.cxx:481
TrigMessageSvc::m_statLevel
Gaudi::Property< unsigned int > m_statLevel
Definition: TrigMessageSvc.h:115
grepfile.ic
int ic
Definition: grepfile.py:33
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
TrigMessageSvc::i_reportMessage
void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: TrigMessageSvc.cxx:283
makeSwHierTags.mh
mh
Definition: makeSwHierTags.py:37
TrigConf::MSGTC::NUM_LEVELS
@ NUM_LEVELS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigMessageSvc::m_thread
std::thread m_thread
Thread for asynchronous reporting.
Definition: TrigMessageSvc.h:197
AthenaInterprocess::UpdateAfterFork::type
static const std::string & type()
Incident type.
Definition: Incidents.h:49
TrigMessageSvc::m_defaultTimeFormat
Gaudi::Property< std::string > m_defaultTimeFormat
Definition: TrigMessageSvc.h:112
TrigMessageSvc::m_stats
Gaudi::Property< bool > m_stats
Definition: TrigMessageSvc.h:114
TrigMessageSvc::m_doSuppress
bool m_doSuppress
is suppression currently enabled?
Definition: TrigMessageSvc.h:189
TrigMessageSvc::i_reportERS
void i_reportERS(const Message &msg) const
Report message to online messaging system (ERS)
Definition: TrigMessageSvc.cxx:375
TrigMessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: TrigMessageSvc.h:171
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
TrigMessageSvc::m_msgHashCount
std::map< size_t, unsigned int > m_msgHashCount
counts per message hash
Definition: TrigMessageSvc.h:184
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigMessageSvc::m_publishLevel
Gaudi::Property< unsigned int > m_publishLevel
Definition: TrigMessageSvc.h:117
TrigMessageSvc::m_asyncReporting
bool m_asyncReporting
(
Definition: TrigMessageSvc.h:196
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
copySelective.source
string source
Definition: copySelective.py:32
TrigMessageSvc::m_slotMsgCount
std::unordered_map< EventContext::ContextID_t, std::pair< EventContext::ContextEvt_t, MsgAry > > m_slotMsgCount
counts per slot and level
Definition: TrigMessageSvc.h:186
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
get_generator_info.error
error
Definition: get_generator_info.py:40
TrigMessageSvc::setupLimits
void setupLimits(Gaudi::Details::PropertyBase &prop)
Definition: TrigMessageSvc.cxx:147
TrigMessageSvc::m_useERS
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_useERS
Special properties to control output to ERS of individual sources.
Definition: TrigMessageSvc.h:155
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
run.Message
Message
Definition: run.py:57
TrigMessageSvc::m_suppressRunningOnly
Gaudi::Property< bool > m_suppressRunningOnly
Definition: TrigMessageSvc.h:124
TrigMessageSvc::m_suppress
Gaudi::Property< bool > m_suppress
Definition: TrigMessageSvc.h:123
TrigMessageSvc::bookHistograms
void bookHistograms()
Definition: TrigMessageSvc.cxx:114
ServiceHandle< ITHistSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TrigMessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: TrigMessageSvc.h:121