The Gaudi Framework  v30r4 (9b837755)
MessageSvc.cpp
Go to the documentation of this file.
1 #ifdef _WIN32
2 // Avoid conflicts between windows and the message service.
3 #define NOMSG
4 #define NOGDI
5 #endif
6 
7 #include "MessageSvc.h"
9 #include "GaudiKernel/Kernel.h"
10 #include "GaudiKernel/Message.h"
11 #include "GaudiKernel/StatusCode.h"
12 #include "GaudiKernel/System.h"
13 
14 #include <fstream>
15 #include <iostream>
16 #include <sstream>
17 
18 namespace
19 {
20 
21  // erase_if functions for containers which do NOT invalidate iterators
22  // after the erase point, eg.std::{unordered_}{,multi}map, std::{forward_,}list.
23  // To be explicit: this does NOT work with std::vector.
24 
25  // TODO: replace with std::experimental::erase_if (Libraries Fundamental TS v2)
26 
27  template <typename Container, typename Iterator, typename Predicate>
28  void erase_if( Container& c, Iterator first, Iterator last, Predicate pred )
29  {
30  while ( first != last ) {
31  if ( pred( *first ) )
32  first = c.erase( first );
33  else
34  ++first;
35  }
36  }
37 
38  template <typename Container, typename Predicate>
39  void erase_if( Container& c, Predicate pred )
40  {
41  return erase_if( c, std::begin( c ), std::end( c ), std::forward<Predicate>( pred ) );
42  }
43 
44  template <typename Container, typename Iterator, typename Predicate>
45  void erase_if( Container& c, std::pair<Iterator, Iterator> range, Predicate pred )
46  {
47  return erase_if( c, std::move( range.first ), std::move( range.second ), std::forward<Predicate>( pred ) );
48  }
49 
50  std::string colTrans( const std::string& col, int offset )
51  {
52  int icol = 0;
53  if ( col == "black" )
54  icol = MSG::BLACK;
55  else if ( col == "red" )
56  icol = MSG::RED;
57  else if ( col == "green" )
58  icol = MSG::GREEN;
59  else if ( col == "yellow" )
60  icol = MSG::YELLOW;
61  else if ( col == "blue" )
62  icol = MSG::BLUE;
63  else if ( col == "purple" )
64  icol = MSG::PURPLE;
65  else if ( col == "cyan" )
66  icol = MSG::CYAN;
67  else if ( col == "white" )
68  icol = MSG::WHITE;
69  else
70  icol = 8;
71  return std::to_string( icol + offset );
72  }
73 }
74 
75 // Instantiation of a static factory class used by clients to create
76 // instances of this service
78 
79 static const std::string levelNames[MSG::NUM_LEVELS] = {"NIL", "VERBOSE", "DEBUG", "INFO",
80  "WARNING", "ERROR", "FATAL", "ALWAYS"};
81 
82 // Constructor
83 MessageSvc::MessageSvc( const std::string& name, ISvcLocator* svcloc ) : base_class( name, svcloc )
84 {
85 
86  m_outputLevel.declareUpdateHandler( [svcloc]( Gaudi::Details::PropertyBase& ) {
87  SmartIF<IAppMgrUI> app = svcloc;
88  if ( app ) app->outputLevelUpdate();
89  } );
90 
91 #ifndef NDEBUG
92  // initialize the MsgStream static flag.
94 #endif
95 
96  for ( int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
97  m_logColors[ic].declareUpdateHandler( &MessageSvc::setupColors, this );
98  m_msgLimit[ic].declareUpdateHandler( &MessageSvc::setupLimits, this );
99  m_thresholdProp[ic].declareUpdateHandler( &MessageSvc::setupThreshold, this );
100  }
101 
102  m_logColors[MSG::FATAL].set( {"blue", "red"} );
103  m_logColors[MSG::ERROR].set( {"white", "red"} );
104  m_logColors[MSG::WARNING].set( {"yellow"} );
105 
107 }
108 
109 //#############################################################################
110 
113 {
115  if ( sc.isFailure() ) return sc;
116 
117 #ifdef _WIN32
118  m_color = false;
119 #endif
120 
121  // make sure the map of logged stream names is initialized
122  setupLogStreams();
123 
124  return StatusCode::SUCCESS;
125 }
126 
127 //#############################################################################
128 
131 {
133  return initialize();
134 }
135 
136 //#############################################################################
137 
139 {
140  const std::string& pname = prop.name();
141  int level;
142  if ( pname == "fatalColorCode" )
143  level = MSG::FATAL;
144  else if ( pname == "errorColorCode" )
145  level = MSG::ERROR;
146  else if ( pname == "warningColorCode" )
147  level = MSG::WARNING;
148  else if ( pname == "infoColorCode" )
149  level = MSG::INFO;
150  else if ( pname == "debugColorCode" )
151  level = MSG::DEBUG;
152  else if ( pname == "verboseColorCode" )
153  level = MSG::VERBOSE;
154  else if ( pname == "alwaysColorCode" )
155  level = MSG::ALWAYS;
156  else {
157  throw GaudiException( "ERROR: Unknown message color parameter: " + pname, name(), StatusCode::FAILURE );
158  }
159 
160  auto& code = m_logColorCodes[level];
161 
162  const auto& col_desc = m_logColors[level].value();
163 
164  if ( col_desc.size() == 1 ) {
165  const std::string& desc = col_desc[0];
166  if ( desc.empty() ) {
167  code = "";
168  } else if ( desc[0] == '[' ) {
169  code = "\033" + desc;
170  } else {
171  code = "\033[" + colTrans( desc, 90 ) + ";1m";
172  }
173  } else if ( col_desc.size() == 2 ) {
174  code = "\033[" + colTrans( col_desc[0], 90 ) + ";" + colTrans( col_desc[1], 100 ) + ";1m";
175  } else { // empty desc: no color
176  code = "";
177  }
178 }
179 //#############################################################################
180 
182 {
183  // Just report problems in the settings of the limits and unknown limit parameters
184  if ( prop.name() == "alwaysLimit" ) {
185  Gaudi::Property<int>* p = dynamic_cast<Gaudi::Property<int>*>( &prop );
186  if ( p && p->value() != 0 ) {
187  std::cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
188  p->setValue( 0 );
189  }
190  } else if ( prop.name() == "defaultLimit" ) {
191  for ( int i = MSG::VERBOSE; i < MSG::NUM_LEVELS; ++i ) {
192  if ( i != MSG::ALWAYS ) {
193  m_msgLimit[i] = m_msgLimit[MSG::NIL].value();
194  }
195  }
196  } else if ( prop.name() != "fatalLimit" && prop.name() != "errorLimit" && prop.name() != "warningLimit" &&
197  prop.name() == "infoLimit" && prop.name() == "debugLimit" && prop.name() == "verboseLimit" ) {
198  std::cout << "MessageSvc ERROR: Unknown message limit parameter: " << prop.name() << std::endl;
199  return;
200  }
201 }
202 //#############################################################################
203 
205 {
206 
207  static const std::array<std::pair<const char*, MSG::Level>, 7> tbl{{{"setFatal", MSG::FATAL},
208  {"setError", MSG::ERROR},
209  {"setWarning", MSG::WARNING},
210  {"setInfo", MSG::INFO},
211  {"setDebug", MSG::DEBUG},
212  {"setVerbose", MSG::VERBOSE},
213  {"setAlways", MSG::ALWAYS}}};
214 
215  auto i = std::find_if( std::begin( tbl ), std::end( tbl ),
216  [&]( const std::pair<const char*, MSG::Level>& t ) { return prop.name() == t.first; } );
217  if ( i == std::end( tbl ) ) {
218  std::cerr << "MessageSvc ERROR: Unknown message threshold parameter: " << prop.name() << std::endl;
219  return;
220  }
221  int ic = i->second;
222 
224  if ( !sap ) {
225  std::cerr << "could not dcast " << prop.name()
226  << " to a Gaudi::Property<std::vector<std::string>> (which it should be!)" << std::endl;
227  } else {
228  for ( auto& i : sap->value() ) setOutputLevel( i, ic );
229  }
230 }
231 
232 //#############################################################################
233 
234 #ifdef NDEBUG
236 #else
238 {
239  if ( prop.name() == "countInactive" ) {
240  Gaudi::Property<bool>* p = dynamic_cast<Gaudi::Property<bool>*>( &prop );
241  if ( p ) MsgStream::enableCountInactive( p->value() );
242  }
243 }
244 #endif
245 
246 //#############################################################################
249 {
250 
251  m_suppress = false;
252 
253  {
255 
256  if ( m_stats ) {
257  os << "Summarizing all message counts" << std::endl;
258  } else {
259  os << "Listing sources of suppressed message: " << std::endl;
260  }
261 
262  os << "=====================================================" << std::endl;
263  os << " Message Source | Level | Count" << std::endl;
264  os << "-----------------------------+---------+-------------" << std::endl;
265 
266  bool found( false );
267 
268  for ( auto itr = m_sourceMap.begin(); itr != m_sourceMap.end(); ++itr ) {
269  for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
270  if ( ( itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
271  ( m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value() ) ) {
272  os << " ";
273  os.width( 28 );
274  os.setf( std::ios_base::left, std::ios_base::adjustfield );
275  os << itr->first;
276  os << "|";
277 
278  os.width( 8 );
279  os.setf( std::ios_base::right, std::ios_base::adjustfield );
280  os << levelNames[ic];
281  os << " |";
282 
283  os.width( 9 );
284  os << itr->second.msg[ic];
285  os << std::endl;
286 
287  found = true;
288  }
289  }
290  }
291  os << "=====================================================" << std::endl;
292  if ( found || m_stats ) std::cout << os.str();
293  }
294 
295 #ifndef NDEBUG
296  if ( m_inactCount.value() ) {
297 
299  os << "Listing sources of Unprotected and Unseen messages\n";
300 
301  bool found( false );
302 
303  unsigned int ml( 0 );
304  for ( const auto& itr : m_inactiveMap ) {
305  for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
306  if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) {
307  ml = itr.first.length();
308  }
309  }
310  }
311 
312  for ( unsigned int i = 0; i < ml + 25; ++i ) os << "=";
313 
314  os << std::endl << " ";
315  os.width( ml + 2 );
316  os.setf( std::ios_base::left, std::ios_base::adjustfield );
317  os << "Message Source";
318  os.width( 1 );
319  os << "| Level | Count" << std::endl;
320 
321  for ( unsigned int i = 0; i < ml + 3; ++i ) os << "-";
322  os << "+---------+-----------" << std::endl;
323 
324  for ( auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
325  for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
326  if ( itr->second.msg[ic] != 0 ) {
327  os << " ";
328  os.width( ml + 2 );
329  os.setf( std::ios_base::left, std::ios_base::adjustfield );
330  os << itr->first;
331 
332  os << "|";
333 
334  os.width( 8 );
335  os.setf( std::ios_base::right, std::ios_base::adjustfield );
336  os << levelNames[ic];
337 
338  os << " |";
339 
340  os.width( 9 );
341  os << itr->second.msg[ic];
342 
343  os << std::endl;
344 
345  found = true;
346  }
347  }
348  }
349  for ( unsigned int i = 0; i < ml + 25; ++i ) os << "=";
350  os << std::endl;
351 
352  if ( found ) std::cout << os.str();
353  }
354 #endif
355 
356  return StatusCode::SUCCESS;
357 }
358 
359 //#############################################################################
360 // ---------------------------------------------------------------------------
361 // Routine: reportMessage
362 // Purpose: dispatches a message to the relevant streams.
363 // ---------------------------------------------------------------------------
364 //
366 {
368  i_reportMessage( msg, outputLevel );
369 }
370 
372 {
373  int key = msg.getType();
374 
375  ++m_msgCount[key];
376 
377  const Message* cmsg = &msg;
378 
379  // processing logged streams
380  if ( !m_loggedStreams.empty() ) {
381  auto iLog = m_loggedStreams.find( msg.getSource() );
382  if ( m_loggedStreams.end() != iLog ) {
383  ( *iLog->second ) << *cmsg << std::endl;
384  }
385  }
386 
387  if ( m_suppress.value() || m_stats.value() ) {
388 
389  // Increase the counter of 'key' type of messages for the source and
390  // get the new value.
391  const int nmsg = ++( m_sourceMap[msg.getSource()].msg[key] );
392 
393  if ( m_suppress.value() && m_msgLimit[key] != 0 ) {
394  if ( nmsg > m_msgLimit[key] ) return;
395  if ( nmsg == m_msgLimit[key] ) {
396  std::string txt = levelNames[key] + " message limit (" + std::to_string( m_msgLimit[key].value() ) +
397  ") reached for " + msg.getSource() + ". Suppressing further output.";
398  cmsg = new Message( msg.getSource(), MSG::WARNING, std::move( txt ) );
399  cmsg->setFormat( msg.getFormat() );
400  }
401  }
402  }
403 
404  auto range = m_streamMap.equal_range( key );
405  if ( range.first != m_streamMap.end() ) {
406  std::for_each( range.first, range.second,
407  [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
408  } else if ( key >= outputLevel ) {
409  msg.setFormat( m_defaultFormat );
411  if ( !m_color ) {
412  ( *m_defaultStream ) << *cmsg << std::endl << std::flush;
413  } else {
414  ( *m_defaultStream ) << m_logColorCodes[key] << *cmsg << "\033[m" << std::endl << std::flush;
415  }
416  }
417 
418  if ( cmsg != &msg ) {
419  delete cmsg;
420  }
421 }
422 
423 //#############################################################################
424 // ---------------------------------------------------------------------------
425 // Routine: reportMessage
426 // Purpose: dispatches a message to the relevant streams.
427 // ---------------------------------------------------------------------------
428 //
430 
431 //#############################################################################
432 // ---------------------------------------------------------------------------
433 // Routine: reportMessage
434 // Purpose: dispatches a message to the relevant streams.
435 // ---------------------------------------------------------------------------
436 //
437 void MessageSvc::reportMessage( const char* source, int type, const char* message )
438 {
439  reportMessage( Message{source, type, message} );
440 }
441 
442 //#############################################################################
443 // ---------------------------------------------------------------------------
444 // Routine: reportMessage
445 // Purpose: dispatches a message to the relevant streams.
446 // ---------------------------------------------------------------------------
447 //
448 void MessageSvc::reportMessage( const std::string& source, int type, const std::string& message )
449 {
450  reportMessage( Message{source, type, message} );
451 }
452 
453 //#############################################################################
454 // ---------------------------------------------------------------------------
455 // Routine: sendMessage
456 // Purpose: finds a message for a given status code and dispatches it.
457 // ---------------------------------------------------------------------------
458 //
459 void MessageSvc::reportMessage( const StatusCode& code, const std::string& source )
460 {
462  i_reportMessage( code, source );
463 }
464 
465 void MessageSvc::i_reportMessage( const StatusCode& code, const std::string& source )
466 {
467  int level = outputLevel( source );
468  auto report = [&]( Message mesg ) {
469  mesg.setSource( source );
470  Message stat_code( source, mesg.getType(), "Status Code " + std::to_string( code.getCode() ) );
471  i_reportMessage( std::move( stat_code ), level );
472  i_reportMessage( std::move( mesg ), level );
473  };
474 
475  auto range = m_messageMap.equal_range( code );
476  if ( range.first != m_messageMap.end() ) {
477  std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
478  } else {
479  report( m_defaultMessage );
480  }
481 }
482 
483 //#############################################################################
484 // ---------------------------------------------------------------------------
485 // Routine: insertStream
486 // Purpose: inserts a stream for a message type.
487 // ---------------------------------------------------------------------------
488 //
489 
490 void MessageSvc::insertStream( int key, const std::string& name, std::ostream* stream )
491 {
492  m_streamMap.emplace( key, NamedStream( name, stream ) );
493 }
494 
495 //#############################################################################
496 // ---------------------------------------------------------------------------
497 // Routine: eraseStream
498 // Purpose: erases all the streams for all the message types.
499 // ---------------------------------------------------------------------------
500 //
501 
503 
504 //#############################################################################
505 // ---------------------------------------------------------------------------
506 // Routine: eraseStream
507 // Purpose: erases all the streams for a message type.
508 // ---------------------------------------------------------------------------
509 //
510 
511 void MessageSvc::eraseStream( int message_type ) { m_streamMap.erase( message_type ); }
512 
513 //#############################################################################
514 // ---------------------------------------------------------------------------
515 // Routine: eraseStream
516 // Purpose: erases one stream for a message type.
517 // ---------------------------------------------------------------------------
518 //
519 
520 void MessageSvc::eraseStream( int key, std::ostream* stream )
521 {
522  if ( stream ) {
523  erase_if( m_streamMap, m_streamMap.equal_range( key ),
524  [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
525  }
526 }
527 
528 //#############################################################################
529 // ---------------------------------------------------------------------------
530 // Routine: eraseStream
531 // Purpose: erases one stream for all message types.
532 // ---------------------------------------------------------------------------
533 //
534 
536 {
537  if ( stream ) {
538  erase_if( m_streamMap, [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
539  }
540 }
541 
542 //#############################################################################
543 // ---------------------------------------------------------------------------
544 // Routine: insertMessage
545 // Purpose: inserts a message for a status code.
546 // ---------------------------------------------------------------------------
547 //
548 
550 {
552  m_messageMap.emplace( key, msg );
553 }
554 
555 //#############################################################################
556 // ---------------------------------------------------------------------------
557 // Routine: eraseMessage
558 // Purpose: erases all the messages for all the status codes.
559 // ---------------------------------------------------------------------------
560 //
561 
563 {
566 }
567 
568 //#############################################################################
569 // ---------------------------------------------------------------------------
570 // Routine: eraseMessage
571 // Purpose: erases all the messages for a status code.
572 // ---------------------------------------------------------------------------
573 //
574 
576 {
578  m_messageMap.erase( key );
579 }
580 
581 //#############################################################################
582 // ---------------------------------------------------------------------------
583 // Routine: eraseMessage
584 // Purpose: erases one message for a status code.
585 // ---------------------------------------------------------------------------
586 //
587 
588 void MessageSvc::eraseMessage( const StatusCode& key, const Message& msg )
589 {
591 
592  erase_if( m_messageMap, m_messageMap.equal_range( key ),
593  [&]( MessageMap::const_reference j ) { return j.second == msg; } );
594 }
595 
596 // ---------------------------------------------------------------------------
598 {
599  // ---------------------------------------------------------------------------
600  return m_outputLevel;
601 }
602 
603 // ---------------------------------------------------------------------------
604 int MessageSvc::outputLevel( const std::string& source ) const
605 {
606  // ---------------------------------------------------------------------------
608  auto it = m_thresholdMap.find( source );
609  return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
610 }
611 
612 // ---------------------------------------------------------------------------
613 void MessageSvc::setOutputLevel( int new_level )
614 {
615  // ---------------------------------------------------------------------------
616  m_outputLevel = new_level;
617 }
618 
619 // ---------------------------------------------------------------------------
620 void MessageSvc::setOutputLevel( const std::string& source, int level )
621 {
622  // ---------------------------------------------------------------------------
624 
625  // only write if we really have to...
626  auto i = m_thresholdMap.find( source );
627  if ( i == m_thresholdMap.end() ) {
628  m_thresholdMap[source] = level;
629  } else if ( i->second != level ) {
630  i->second = level;
631  }
632 }
633 
634 // ---------------------------------------------------------------------------
636 {
637  // ---------------------------------------------------------------------------
638  return ( logLevel < MSG::NUM_LEVELS ) ? m_logColorCodes[logLevel] : "";
639 }
640 
641 // ---------------------------------------------------------------------------
643 
644 // ---------------------------------------------------------------------------
646 {
647  ++( m_inactiveMap[source].msg[level] );
648 
651  std::cout << "== inactive message detected from " << source << " ==" << std::endl;
652  std::string t;
653  System::backTrace( t, 25, 0 );
654  std::cout << t << std::endl;
655  }
656 }
657 
658 // ---------------------------------------------------------------------------
660 {
661  // reset state
663 
664  for ( auto& iProp : m_loggedStreamsName ) {
665 
666  std::set<std::string> outFileNames;
667  for ( auto& jProp : m_loggedStreamsName ) {
668  if ( jProp.first != iProp.first ) {
669  outFileNames.insert( jProp.second );
670  }
671  }
672  tee( iProp.first, iProp.second, outFileNames );
673 
674  } //> loop over property entries
675 }
676 
677 // ---------------------------------------------------------------------------
678 void MessageSvc::tee( const std::string& sourceName, const std::string& outFileName,
679  const std::set<std::string>& outFileNames )
680 {
681  const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
682 
683  auto iStream = m_loggedStreams.find( sourceName );
684  if ( iStream != std::end( m_loggedStreams ) ) {
685  m_loggedStreams.erase( iStream );
686  }
687 
688  // before creating a new ofstream, make sure there is no already existing
689  // one with the same file name...
690  for ( auto& iStream : m_loggedStreams ) {
691  if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
692  m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
693  return;
694  }
695  }
696 
697  auto out = std::make_shared<std::ofstream>( outFileName, openMode );
698  if ( out->good() ) m_loggedStreams[sourceName] = std::move( out );
699 }
Gaudi::Property< int > m_outputLevel
Definition: Service.h:182
const std::string & getFormat() const
Get the format string.
Definition: Message.cpp:154
constexpr static const auto FAILURE
Definition: StatusCode.h:88
T setf(T...args)
StatusCode initialize() override
Definition: Service.cpp:63
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
T empty(T...args)
bool setValue(const ValueType &v)
Definition: Property.h:589
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:159
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:180
Implementation of property with value of concrete type.
Definition: Property.h:383
std::string getLogColor(int logLevel) const override
Definition: MessageSvc.cpp:635
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:371
void setupInactCount(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:237
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:194
const std::string name() const
property name
Definition: Property.h:39
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:179
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:194
T to_string(T...args)
T endl(T...args)
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:181
STL namespace.
void setupLogStreams()
Definition: MessageSvc.cpp:659
Gaudi::Property< std::string > m_defaultTimeFormat
Definition: MessageSvc.h:133
MessageSvc(const std::string &name, ISvcLocator *svcloc)
Definition: MessageSvc.cpp:83
T end(T...args)
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:214
int getType() const
Get the message type.
Definition: Message.cpp:87
StatusCode reinitialize() override
Reinitialize Service.
Definition: MessageSvc.cpp:130
void eraseMessage() override
Definition: MessageSvc.cpp:562
bool isFailure() const
Definition: StatusCode.h:139
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
Definition: MessageSvc.h:169
GAUDI_API int backTrace(void **addresses, const int depth)
void setupColors(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:138
virtual void outputLevelUpdate()=0
Function to call to update the outputLevel of the components (after a change in MessageSvc).
STL class.
void eraseStream() override
Definition: MessageSvc.cpp:502
#define DECLARE_COMPONENT(type)
void incrInactiveCount(MSG::Level level, const std::string &src) override
Definition: MessageSvc.cpp:645
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:198
Gaudi::Property< bool > m_inactCount
Definition: MessageSvc.h:167
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Definition: MessageSvc.h:148
Gaudi::Property< unsigned int > m_statLevel
Definition: MessageSvc.h:135
void setOutputLevel(int new_level) override
Definition: MessageSvc.cpp:613
StatusCode initialize() override
Initialize Service.
Definition: MessageSvc.cpp:112
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:182
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:33
T erase(T...args)
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:429
T width(T...args)
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:146
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:34
Gaudi::Property< std::string > m_defaultFormat
Definition: MessageSvc.h:132
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:211
T clear(T...args)
T move(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T flush(T...args)
T insert(T...args)
T find_if(T...args)
void setFormat(std::string msg) const
Set the format string.
Definition: Message.cpp:171
The Message class.
Definition: Message.h:15
StatusCode finalize() override
Finalize Service.
Definition: MessageSvc.cpp:248
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
T begin(T...args)
Print levels enumeration.
Definition: IMessageSvc.h:14
void setTimeFormat(std::string timeFormat) const
Set the time format string.
Definition: Message.cpp:203
T emplace(T...args)
int outputLevel() const override
Definition: MessageSvc.cpp:597
STL class.
void setupLimits(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:181
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:204
Gaudi::Property< bool > m_stats
Definition: MessageSvc.h:134
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:184
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:103
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:196
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
Definition: MessageSvc.h:137
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:587
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:146
T fill(T...args)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:157
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
Definition: MessageSvc.cpp:678
T for_each(T...args)
Gaudi::Property< bool > m_suppress
Definition: MessageSvc.h:166
void insertMessage(const StatusCode &code, const Message &message) override
Definition: MessageSvc.cpp:549
Gaudi::Property< std::map< std::string, std::string > > m_loggedStreamsName
Definition: MessageSvc.h:175
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:31
T equal_range(T...args)
void insertStream(int message_type, const std::string &name, std::ostream *stream) override
Definition: MessageSvc.cpp:490
int messageCount(MSG::Level logLevel) const override
Definition: MessageSvc.cpp:642
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:218