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