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