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