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/Kernel.h"
9 #include "GaudiKernel/Message.h"
10 #include "GaudiKernel/System.h"
11 #include "MessageSvc.h"
12 
13 #include <sstream>
14 #include <iostream>
15 #include <fstream>
16 
17 
18 namespace {
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  while ( first!=last ) {
29  if ( pred(*first) ) first = c.erase(first);
30  else ++first;
31  }
32  }
33 
34  template< typename Container, typename Predicate >
35  void erase_if( Container& c, Predicate pred ) {
36  return erase_if(c, std::begin(c), std::end(c),
37  std::forward<Predicate>(pred) );
38  }
39 
40  template< typename Container, typename Iterator, typename Predicate >
41  void erase_if( Container& c, std::pair<Iterator,Iterator> range, Predicate pred ) {
42  return erase_if(c, std::move(range.first), std::move(range.second),
43  std::forward<Predicate>(pred) );
44  }
45 
46 }
47 
48 // Instantiation of a static factory class used by clients to create
49 // instances of this service
51 
52 static const std::string levelNames[MSG::NUM_LEVELS] = {
53  "NIL", "VERBOSE", "DEBUG", "INFO",
54  "WARNING", "ERROR", "FATAL", "ALWAYS"
55 };
56 
57 // Constructor
59  : base_class( name, svcloc ) {
63  declareProperty( "showStats", m_stats = false );
64  declareProperty( "statLevel", m_statLevel = 0 );
65 
66  // Special properties to control output level of individual sources
74 
76 
77  declareProperty( "fatalColorCode", m_logColors[MSG::FATAL] );
78  declareProperty( "errorColorCode", m_logColors[MSG::ERROR] );
79  declareProperty( "warningColorCode", m_logColors[MSG::WARNING] );
80  declareProperty( "infoColorCode", m_logColors[MSG::INFO] );
81  declareProperty( "debugColorCode", m_logColors[MSG::DEBUG] );
82  declareProperty( "verboseColorCode", m_logColors[MSG::VERBOSE] );
83  declareProperty( "alwaysColorCode", m_logColors[MSG::ALWAYS] );
84 
85  const int defaultLimit = 500;
86  declareProperty( "fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
87  declareProperty( "errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
88  declareProperty( "warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
89  declareProperty( "infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
90  declareProperty( "debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
91  declareProperty( "verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
92  declareProperty( "alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
93 
94  declareProperty( "defaultLimit", m_msgLimit[MSG::NIL] = defaultLimit );
95 
96  declareProperty( "enableSuppression", m_suppress = false );
98  declareProperty( "tracedInactiveSources", m_tracedInactiveSources,
99  "for each message source specified, print a stack trace for"
100  "the unprotected and unseen messages" );
101 #ifndef NDEBUG
102  // initialize the MsgStream static flag.
104 #endif
105 
106  declareProperty( "loggedStreams",
108  "MessageStream sources we want to dump into a logfile" );
109 
110  for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
114  }
115 
117 }
118 
119 //#############################################################################
120 
121 
124  StatusCode sc;
125  sc = Service::initialize();
126  if( sc.isFailure() ) return sc;
127  // Set my own properties
128  sc = setProperties();
129  if (sc.isFailure()) return sc;
130 
131 #ifdef _WIN32
132  m_color = false;
133 #endif
134 
135  //NOTE: m_colMap is used _before_ it is filled here,
136  // i.e. while it is still empty.
137  // Moving this initialization 'up' by eg. just
138  // having a 'static const' colMap does not leave
139  // the results invariant...
140  m_colMap["black"] = MSG::BLACK;
141  m_colMap["red"] = MSG::RED;
142  m_colMap["green"] = MSG::GREEN;
143  m_colMap["yellow"] = MSG::YELLOW;
144  m_colMap["blue"] = MSG::BLUE;
145  m_colMap["purple"] = MSG::PURPLE;
146  m_colMap["cyan"] = MSG::CYAN;
147  m_colMap["white"] = MSG::WHITE;
148 
149  // make sure the map of logged stream names is initialized
150  setupLogStreams();
151 
152  return StatusCode::SUCCESS;
153 }
154 
155 //#############################################################################
156 
160  return initialize();
161 }
162 
163 //#############################################################################
164 
166 
167  if (m_color) {
169  { { MSG::FATAL, { { "[94;101;1m" } } },
170  { MSG::ERROR, { { "[97;101;1m" } } },
171  { MSG::WARNING, { { "[93;1m" } } } } };
172 
173  for (const auto& p : tbl ) {
174  auto &lC = m_logColors[p.first];
175  if (lC.value().empty()) {
176  lC.set(p.second);
177  } else {
179  }
180  }
181 
182  } else {
183 
184  // reset all color codes;
185  for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
186  m_logColors[ic].set( { } );
187  }
188 
189  }
190 
191 }
192 
193 //#############################################################################
194 
196 
197  if (! m_color) return;
198 
200  { {"fatalColorCode", MSG::FATAL },
201  {"errorColorCode", MSG::ERROR },
202  {"warningColorCode", MSG::WARNING },
203  {"infoColorCode", MSG::INFO },
204  {"debugColorCode", MSG::DEBUG },
205  {"verboseColorCode", MSG::VERBOSE },
206  {"alwaysColorCode", MSG::ALWAYS } } };
207 
208  auto i = std::find_if( std::begin(tbl),std::end(tbl),
209  [&](const std::pair<const char*,MSG::Level>& t) {
210  return prop.name() == t.first;
211  } );
212  if (i==std::end(tbl)) {
213  std::cout << "ERROR: Unknown message color parameter: " << prop.name()
214  << std::endl;
215  return;
216  }
217  int ic = i->second;
218 
219  std::string code;
220  auto itr = m_logColors[ic].value().begin();
221 
222  if ( m_logColors[ic].value().size() == 1 ) {
223 
224  if (itr->empty()) {
225  code = "";
226  } else if (itr->compare(0,1,"[") == 0) {
227  code = "\033" + *itr;
228  } else {
229  code = "\033[" + colTrans(*itr, 90) + ";1m";
230  }
231 
232  } else if (m_logColors[ic].value().size() == 2) {
233  auto itr2 = itr + 1;
234 
235  code = "\033[" + colTrans(*itr, 90) + ";"
236  + colTrans(*itr2, 100) + ";1m";
237 
238  }
239 
240  m_logColorCodes[ic] = code;
241 
242 }
243 //#############################################################################
244 
246  // Just report problems in the settings of the limits and unknown limit parameters
247  if (prop.name() == "alwaysLimit") {
248  IntegerProperty *p = dynamic_cast<IntegerProperty*>(&prop);
249  if (p && p->value() != 0) {
250  std::cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
251  p->setValue(0);
252  }
253  } else if (prop.name() == "defaultLimit") {
254  for (int i = MSG::VERBOSE; i< MSG::NUM_LEVELS; ++i) {
255  if (i != MSG::ALWAYS) {
257  }
258  }
259  } else if (prop.name() != "fatalLimit" &&
260  prop.name() != "errorLimit" &&
261  prop.name() != "warningLimit" &&
262  prop.name() == "infoLimit" &&
263  prop.name() == "debugLimit" &&
264  prop.name() == "verboseLimit") {
265  std::cout << "MessageSvc ERROR: Unknown message limit parameter: "
266  << prop.name() << std::endl;
267  return;
268  }
269 }
270 //#############################################################################
271 
273 
275  { { "setFatal", MSG::FATAL },
276  { "setError", MSG::ERROR },
277  { "setWarning", MSG::WARNING },
278  { "setInfo", MSG::INFO },
279  { "setDebug", MSG::DEBUG },
280  { "setVerbose", MSG::VERBOSE },
281  { "setAlways", MSG::ALWAYS } } };
282 
283  auto i = std::find_if( std::begin(tbl),std::end(tbl),
284  [&](const std::pair<const char*,MSG::Level>& t) {
285  return prop.name() == t.first;
286  } );
287  if (i==std::end(tbl)) {
288  std::cerr << "MessageSvc ERROR: Unknown message threshold parameter: "
289  << prop.name() << std::endl;
290  return;
291  }
292  int ic = i->second;
293 
294  StringArrayProperty *sap = dynamic_cast<StringArrayProperty*>( &prop);
295  if (!sap) {
296  std::cerr << "could not dcast " << prop.name()
297  << " to a StringArrayProperty (which it should be!)" << std::endl;
298  } else {
299  for ( auto& i : sap->value() ) setOutputLevel( i, ic );
300  }
301 
302 }
303 
304 //#############################################################################
305 
306 #ifdef NDEBUG
308 #else
310  if (prop.name() == "countInactive") {
311  BooleanProperty *p = dynamic_cast<BooleanProperty*>(&prop);
312  if (p)
314  }
315 }
316 #endif
317 
318 
319 //#############################################################################
322 
323  m_suppress = false;
324 
325  {
327 
328  if (m_stats) {
329  os << "Summarizing all message counts" << std::endl;
330  } else {
331  os << "Listing sources of suppressed message: " << std::endl;
332  }
333 
334  os << "=====================================================" << std::endl;
335  os << " Message Source | Level | Count" << std::endl;
336  os << "-----------------------------+---------+-------------" << std::endl;
337 
338 
339  bool found(false);
340 
341  for (auto itr=m_sourceMap.begin(); itr!=m_sourceMap.end(); ++itr) {
342  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
343  if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
344  (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
345  os << " ";
346  os.width(28);
347  os.setf(std::ios_base::left,std::ios_base::adjustfield);
348  os << itr->first;
349  os << "|";
350 
351  os.width(8);
352  os.setf(std::ios_base::right,std::ios_base::adjustfield);
353  os << levelNames[ic];
354  os << " |";
355 
356  os.width(9);
357  os << itr->second.msg[ic];
358  os << std::endl;
359 
360  found = true;
361  }
362  }
363  }
364  os << "=====================================================" << std::endl;
365  if (found || m_stats) std::cout << os.str();
366  }
367 
368 #ifndef NDEBUG
369  if (m_inactCount.value()) {
370 
372  os << "Listing sources of Unprotected and Unseen messages\n";
373 
374  bool found(false);
375 
376  unsigned int ml(0);
377  for (const auto& itr : m_inactiveMap) {
378  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
379  if (itr.second.msg[ic] != 0 && itr.first.length() > ml) {
380  ml = itr.first.length();
381  }
382  }
383  }
384 
385  for (unsigned int i=0; i<ml+25; ++i) os << "=";
386 
387  os << std::endl << " ";
388  os.width(ml+2);
389  os.setf(std::ios_base::left,std::ios_base::adjustfield);
390  os << "Message Source";
391  os.width(1);
392  os << "| Level | Count" << std::endl;
393 
394  for (unsigned int i=0; i<ml+3; ++i) os << "-";
395  os << "+---------+-----------" << std::endl;
396 
397 
398  for (auto itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
399  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
400  if (itr->second.msg[ic] != 0) {
401  os << " ";
402  os.width(ml+2);
403  os.setf(std::ios_base::left,std::ios_base::adjustfield);
404  os << itr->first;
405 
406  os << "|";
407 
408  os.width(8);
409  os.setf(std::ios_base::right,std::ios_base::adjustfield);
410  os << levelNames[ic];
411 
412  os << " |";
413 
414  os.width(9);
415  os << itr->second.msg[ic];
416 
417  os << std::endl;
418 
419  found = true;
420  }
421  }
422  }
423  for (unsigned int i=0; i<ml+25; ++i) os << "=";
424  os << std::endl;
425 
426  if (found) std::cout << os.str();
427  }
428 #endif
429 
430  return StatusCode::SUCCESS;
431 }
432 
433 //#############################################################################
435  auto itr = m_colMap.find(col);
436  int icol = offset + ( (itr != m_colMap.end()) ? itr->second : 8 );
437  return std::to_string( icol );
438 }
439 
440 //#############################################################################
441 // ---------------------------------------------------------------------------
442 // Routine: reportMessage
443 // Purpose: dispatches a message to the relevant streams.
444 // ---------------------------------------------------------------------------
445 //
446 void MessageSvc::reportMessage( const Message& msg, int outputLevel ) {
448  i_reportMessage(msg, outputLevel);
449 }
450 
451 void MessageSvc::i_reportMessage( const Message& msg, int outputLevel ) {
452  int key = msg.getType();
453 
454  ++m_msgCount[key];
455 
456  const Message *cmsg = &msg;
457 
458  // processing logged streams
459  if ( !m_loggedStreams.empty() ) {
460  auto iLog = m_loggedStreams.find( msg.getSource() );
461  if ( m_loggedStreams.end() != iLog ) {
462  (*iLog->second) << *cmsg << std::endl;
463  }
464  }
465 
466  if ( m_suppress.value() || m_stats.value() ) {
467 
468  // Increase the counter of 'key' type of messages for the source and
469  // get the new value.
470  const int nmsg = ++(m_sourceMap[msg.getSource()].msg[key]);
471 
472  if (m_suppress.value() && m_msgLimit[key] != 0 ) {
473  if (nmsg > m_msgLimit[key]) return;
474  if (nmsg == m_msgLimit[key]) {
475  std::string txt = levelNames[key] + " message limit ("
476  + std::to_string( m_msgLimit[key].value() )
477  + ") reached for " + msg.getSource() + ". Suppressing further output.";
478  cmsg = new Message(msg.getSource(), MSG::WARNING, std::move(txt));
479  cmsg->setFormat(msg.getFormat());
480  }
481  }
482  }
483 
484  auto range = m_streamMap.equal_range( key );
485  if ( range.first != m_streamMap.end() ) {
486  std::for_each( range.first,range.second, [&](StreamMap::const_reference sm) {
487  *sm.second.second << *cmsg << std::endl;
488  });
489  } else if ( key >= outputLevel ) {
492  if (!m_color) {
493  (*m_defaultStream) << *cmsg << std::endl << std::flush;
494  } else {
495  (*m_defaultStream) << m_logColorCodes[key] << *cmsg << "\033[m"
496  << std::endl << std::flush;
497  }
498  }
499 
500  if (cmsg != &msg) { delete cmsg; }
501 
502 }
503 
504 //#############################################################################
505 // ---------------------------------------------------------------------------
506 // Routine: reportMessage
507 // Purpose: dispatches a message to the relevant streams.
508 // ---------------------------------------------------------------------------
509 //
511  reportMessage(msg, outputLevel(msg.getSource()));
512 }
513 
514 //#############################################################################
515 // ---------------------------------------------------------------------------
516 // Routine: reportMessage
517 // Purpose: dispatches a message to the relevant streams.
518 // ---------------------------------------------------------------------------
519 //
520 void MessageSvc::reportMessage (const char* source,
521  int type,
522  const char* message) {
523  reportMessage( Message{ source, type, message } );
524 }
525 
526 //#############################################################################
527 // ---------------------------------------------------------------------------
528 // Routine: reportMessage
529 // Purpose: dispatches a message to the relevant streams.
530 // ---------------------------------------------------------------------------
531 //
533  int type,
534  const std::string& message) {
535  reportMessage( Message{source, type, message} );
536 }
537 
538 //#############################################################################
539 // ---------------------------------------------------------------------------
540 // Routine: sendMessage
541 // Purpose: finds a message for a given status code and dispatches it.
542 // ---------------------------------------------------------------------------
543 //
545  const std::string& source)
546 {
548  i_reportMessage(code, source);
549 }
550 
552  const std::string& source)
553 {
554  int level = outputLevel(source);
555  auto report = [&](Message mesg) {
556  mesg.setSource( source );
557  Message stat_code( source, mesg.getType(), "Status Code " + std::to_string( code.getCode() ) );
558  i_reportMessage( std::move(stat_code), level );
559  i_reportMessage( std::move(mesg), level );
560  };
561 
562  auto range = m_messageMap.equal_range( code );
563  if ( range.first != m_messageMap.end() ) {
564  std::for_each( range.first, range.second,
565  [&](MessageMap::const_reference sm) { report(sm.second); } );
566  } else {
567  report(m_defaultMessage);
568  }
569 }
570 
571 //#############################################################################
572 // ---------------------------------------------------------------------------
573 // Routine: insertStream
574 // Purpose: inserts a stream for a message type.
575 // ---------------------------------------------------------------------------
576 //
577 
579  const std::string& name,
580  std::ostream *stream)
581 {
582  m_streamMap.emplace( key, NamedStream(name,stream) );
583 }
584 
585 //#############################################################################
586 // ---------------------------------------------------------------------------
587 // Routine: eraseStream
588 // Purpose: erases all the streams for all the message types.
589 // ---------------------------------------------------------------------------
590 //
591 
593 {
594  m_streamMap.clear();
595 }
596 
597 //#############################################################################
598 // ---------------------------------------------------------------------------
599 // Routine: eraseStream
600 // Purpose: erases all the streams for a message type.
601 // ---------------------------------------------------------------------------
602 //
603 
604 void MessageSvc::eraseStream( int message_type )
605 {
606  m_streamMap.erase( message_type );
607 }
608 
609 //#############################################################################
610 // ---------------------------------------------------------------------------
611 // Routine: eraseStream
612 // Purpose: erases one stream for a message type.
613 // ---------------------------------------------------------------------------
614 //
615 
616 void MessageSvc::eraseStream( int key, std::ostream* stream ) {
617  if ( stream ) {
618  erase_if( m_streamMap, m_streamMap.equal_range(key),
619  [&](StreamMap::const_reference j)
620  { return j.second.second == stream; } );
621  }
622 }
623 
624 //#############################################################################
625 // ---------------------------------------------------------------------------
626 // Routine: eraseStream
627 // Purpose: erases one stream for all message types.
628 // ---------------------------------------------------------------------------
629 //
630 
632  if ( stream ) {
633  erase_if( m_streamMap, [&](StreamMap::const_reference j)
634  { return j.second.second == stream; } );
635  }
636 }
637 
638 //#############################################################################
639 // ---------------------------------------------------------------------------
640 // Routine: insertMessage
641 // Purpose: inserts a message for a status code.
642 // ---------------------------------------------------------------------------
643 //
644 
646 {
648  m_messageMap.emplace( key, msg );
649 }
650 
651 //#############################################################################
652 // ---------------------------------------------------------------------------
653 // Routine: eraseMessage
654 // Purpose: erases all the messages for all the status codes.
655 // ---------------------------------------------------------------------------
656 //
657 
659 {
662 }
663 
664 //#############################################################################
665 // ---------------------------------------------------------------------------
666 // Routine: eraseMessage
667 // Purpose: erases all the messages for a status code.
668 // ---------------------------------------------------------------------------
669 //
670 
672 {
674  m_messageMap.erase( key );
675 }
676 
677 //#############################################################################
678 // ---------------------------------------------------------------------------
679 // Routine: eraseMessage
680 // Purpose: erases one message for a status code.
681 // ---------------------------------------------------------------------------
682 //
683 
684 void MessageSvc::eraseMessage( const StatusCode& key, const Message& msg )
685 {
687 
688  erase_if( m_messageMap, m_messageMap.equal_range(key),
689  [&](MessageMap::const_reference j) { return j.second==msg; } ) ;
690 }
691 
692 // ---------------------------------------------------------------------------
694 // ---------------------------------------------------------------------------
695  return m_outputLevel;
696 }
697 
698 // ---------------------------------------------------------------------------
699 int MessageSvc::outputLevel( const std::string& source ) const {
700 // ---------------------------------------------------------------------------
702  auto it = m_thresholdMap.find( source );
703  return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
704 }
705 
706 // ---------------------------------------------------------------------------
707 void MessageSvc::setOutputLevel(int new_level) {
708 // ---------------------------------------------------------------------------
709  m_outputLevel = new_level;
710 }
711 
712 // ---------------------------------------------------------------------------
713 void MessageSvc::setOutputLevel(const std::string& source, int level) {
714 // ---------------------------------------------------------------------------
716 
717  // only write if we really have to...
718  auto i = m_thresholdMap.find( source );
719  if (i == m_thresholdMap.end()) {
720  m_thresholdMap[source] = level;
721  } else if (i->second!=level) {
722  i->second = level;
723  }
724 }
725 
726 // ---------------------------------------------------------------------------
728 // ---------------------------------------------------------------------------
729  return (logLevel < MSG::NUM_LEVELS) ? m_logColorCodes[logLevel] : "" ;
730 }
731 
732 // ---------------------------------------------------------------------------
734 
735  return m_msgCount[level];
736 
737 }
738 
739 // ---------------------------------------------------------------------------
740 void
742  ++(m_inactiveMap[source].msg[level]);
743 
746  source) != end(m_tracedInactiveSources)) {
747  std::cout << "== inactive message detected from "
748  << source << " ==" << std::endl;
749  std::string t;
750  System::backTrace(t, 25, 0);
751  std::cout << t << std::endl;
752  }
753 }
754 
755 // ---------------------------------------------------------------------------
757 {
758  // reset state
760 
761  for ( auto& iProp : m_loggedStreamsName ) {
762 
763  std::set<std::string> outFileNames;
764  for ( auto& jProp : m_loggedStreamsName ) {
765  if ( jProp.first != iProp.first ) {
766  outFileNames.insert( jProp.second );
767  }
768  }
769  tee( iProp.first, iProp.second, outFileNames );
770 
771  }//> loop over property entries
772 }
773 
774 // ---------------------------------------------------------------------------
775 void MessageSvc::tee( const std::string& sourceName,
776  const std::string& outFileName,
777  const std::set<std::string>& outFileNames )
778 {
779  const std::ios_base::openmode openMode = std::ios_base::out |
780  std::ios_base::trunc;
781 
782  auto iStream = m_loggedStreams.find( sourceName );
783  if ( iStream != std::end(m_loggedStreams) ) {
784  m_loggedStreams.erase( iStream );
785  }
786 
787  // before creating a new ofstream, make sure there is no already existing
788  // one with the same file name...
789  for (auto& iStream : m_loggedStreams ) {
790  if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
791  m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
792  return;
793  }
794  }
795 
796  auto out = std::make_shared<std::ofstream>( outFileName, openMode );
797  if ( out->good() ) m_loggedStreams[sourceName] = std::move(out);
798 
799 }
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:150
const std::string & getFormat() const
Get the format string.
Definition: Message.cpp:176
std::string colTrans(std::string, int)
Definition: MessageSvc.cpp:434
T setf(T...args)
StatusCode initialize() override
Definition: Service.cpp:68
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
T empty(T...args)
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:138
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:170
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
const std::string & name() const
property name
Definition: Property.h:45
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:451
ColorMap m_colMap
Definition: MessageSvc.h:168
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:139
tuple c
Definition: gaudirun.py:391
T to_string(T...args)
T endl(T...args)
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
void setupLimits(Property &prop)
Definition: MessageSvc.cpp:245
void setupInactCount(Property &prop)
Definition: MessageSvc.cpp:309
STL namespace.
void setupLogStreams()
Definition: MessageSvc.cpp:756
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
Definition: Property.h:406
MessageSvc(const std::string &name, ISvcLocator *svcloc)
Definition: MessageSvc.cpp:58
T end(T...args)
bool set(const TYPE &value)
update the value of the property/check the verifier
Definition: Property.h:434
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
int getType() const
Get the message type.
Definition: Message.cpp:93
StatusCode reinitialize() override
Reinitialize Service.
Definition: MessageSvc.cpp:158
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:34
void eraseMessage() override
Definition: MessageSvc.cpp:658
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GAUDI_API int backTrace(void **addresses, const int depth)
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
UnsignedIntegerProperty m_statLevel
Definition: MessageSvc.h:148
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
STL class.
void eraseStream() override
Definition: MessageSvc.cpp:592
void incrInactiveCount(MSG::Level level, const std::string &src) override
Definition: MessageSvc.cpp:741
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:173
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:162
std::string getLogColor(int logLevel) const override
Definition: MessageSvc.cpp:727
void setOutputLevel(int new_level) override
Definition: MessageSvc.cpp:707
string type
Definition: gaudirun.py:151
StatusCode initialize() override
Initialize Service.
Definition: MessageSvc.cpp:123
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:142
static const std::string getDefaultTimeFormat()
Get the default time format string.
Definition: Message.cpp:226
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T erase(T...args)
static const std::string getDefaultFormat()
Get the default format string.
Definition: Message.cpp:187
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:510
def lock(file)
Definition: locker.py:16
T width(T...args)
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:187
T clear(T...args)
T move(T...args)
const TYPE & value() const
explicit conversion
Definition: Property.h:341
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
T flush(T...args)
T insert(T...args)
T find_if(T...args)
StringArrayProperty m_thresholdProp[MSG::NUM_LEVELS]
Properties controlling.
Definition: MessageSvc.h:145
void setFormat(std::string msg) const
Set the format string.
Definition: Message.cpp:200
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
The Message class.
Definition: Message.h:14
StatusCode finalize() override
Finalize Service.
Definition: MessageSvc.cpp:321
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18
T begin(T...args)
std::string m_defaultFormat
Default format for the messages.
Definition: MessageSvc.h:143
Print levels enumeration.
Definition: IMessageSvc.h:14
void setTimeFormat(std::string timeFormat) const
Set the time format string.
Definition: Message.cpp:239
void setupColors(Property &prop)
Definition: MessageSvc.cpp:195
T emplace(T...args)
STL class.
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:162
void initColors(Property &prop)
Definition: MessageSvc.cpp:165
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:152
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:115
int messageCount(MSG::Level logLevel) const override
Definition: MessageSvc.cpp:733
BooleanProperty m_color
Definition: MessageSvc.h:146
BooleanProperty m_inactCount
Definition: MessageSvc.h:163
T fill(T...args)
int outputLevel() const override
Definition: MessageSvc.cpp:693
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
Definition: MessageSvc.cpp:775
BooleanProperty m_stats
Definition: MessageSvc.h:147
std::map< std::string, std::string > m_loggedStreamsName
Definition: MessageSvc.h:172
std::vector< std::string > m_tracedInactiveSources
Definition: MessageSvc.h:164
T for_each(T...args)
void insertMessage(const StatusCode &code, const Message &message) override
Definition: MessageSvc.cpp:645
list i
Definition: ana.py:128
BooleanProperty m_suppress
Definition: MessageSvc.h:163
void setupThreshold(Property &prop)
Definition: MessageSvc.cpp:272
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
Definition: MessageSvc.h:144
T equal_range(T...args)
void insertStream(int message_type, const std::string &name, std::ostream *stream) override
Definition: MessageSvc.cpp:578
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:149
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:194