32 declareProperty(
"showStats", m_stats =
false );
33 declareProperty(
"statLevel", m_statLevel = 0 );
36 declareProperty(
"setVerbose", m_thresholdProp[
MSG::VERBOSE] );
37 declareProperty(
"setDebug", m_thresholdProp[
MSG::DEBUG] );
38 declareProperty(
"setInfo", m_thresholdProp[
MSG::INFO] );
39 declareProperty(
"setWarning", m_thresholdProp[
MSG::WARNING] );
40 declareProperty(
"setError", m_thresholdProp[
MSG::ERROR] );
41 declareProperty(
"setFatal", m_thresholdProp[
MSG::FATAL] );
42 declareProperty(
"setAlways", m_thresholdProp[
MSG::ALWAYS] );
44 declareProperty(
"useColors", m_color=
false);
47 declareProperty(
"fatalColorCode", m_logColors[MSG::FATAL] );
48 declareProperty(
"errorColorCode", m_logColors[MSG::ERROR] );
49 declareProperty(
"warningColorCode", m_logColors[MSG::WARNING] );
50 declareProperty(
"infoColorCode", m_logColors[MSG::INFO] );
51 declareProperty(
"debugColorCode", m_logColors[MSG::DEBUG] );
52 declareProperty(
"verboseColorCode", m_logColors[MSG::VERBOSE] );
53 declareProperty(
"alwaysColorCode", m_logColors[MSG::ALWAYS] );
55 const int defaultLimit = 500;
56 declareProperty(
"fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
57 declareProperty(
"errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
58 declareProperty(
"warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
59 declareProperty(
"infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
60 declareProperty(
"debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
61 declareProperty(
"verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
62 declareProperty(
"alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
64 declareProperty(
"defaultLimit", m_msgLimit[
MSG::NIL] = defaultLimit );
66 declareProperty(
"enableSuppression", m_suppress =
false );
73 declareProperty(
"loggedStreams",
75 "MessageStream sources we want to dump into a logfile" );
105 for ( ; iStream != endStream; ++iStream ) {
106 delete iStream->second;
123 sc = setProperties();
157 if (m_color ==
true) {
159 if (m_logColors[
MSG::FATAL].value().size() == 0) {
167 if (m_logColors[
MSG::ERROR].value().size() == 0) {
188 m_logColors[ic].set( def );
199 if (! m_color)
return;
202 if (prop.
name() ==
"fatalColorCode") {
204 }
else if (prop.
name() ==
"errorColorCode") {
206 }
else if (prop.
name() ==
"warningColorCode") {
208 }
else if (prop.
name() ==
"infoColorCode") {
210 }
else if (prop.
name() ==
"debugColorCode") {
212 }
else if (prop.
name() ==
"verboseColorCode") {
214 }
else if (prop.
name() ==
"alwaysColorCode") {
217 cout <<
"ERROR: Unknown message color parameter: " << prop.
name()
224 itr = m_logColors[ic].value().
begin();
226 if ( m_logColors[ic].value().size() == 1 ) {
230 }
else if (itr->substr(0,1) ==
"[") {
231 code =
"\033" + *itr;
233 code =
"\033[" + colTrans(*itr, 90) +
";1m";
236 }
else if (m_logColors[ic].value().size() == 2) {
239 code =
"\033[" + colTrans(*itr, 90) +
";"
240 + colTrans(*itr2, 100) +
";1m";
244 m_logColorCodes[ic] = code;
251 if (prop.
name() ==
"alwaysLimit") {
253 if (p && p->
value() != 0) {
254 cout <<
"MessageSvc ERROR: cannot suppress ALWAYS messages" <<
endl;
257 }
else if (prop.
name() ==
"defaultLimit") {
260 m_msgLimit[
i] = m_msgLimit[
MSG::NIL].value();
263 }
else if (prop.
name() !=
"fatalLimit" &&
264 prop.
name() !=
"errorLimit" &&
265 prop.
name() !=
"warningLimit" &&
266 prop.
name() ==
"infoLimit" &&
267 prop.
name() ==
"debugLimit" &&
268 prop.
name() ==
"verboseLimit") {
269 cout <<
"MessageSvc ERROR: Unknown message limit parameter: "
279 if (prop.
name() ==
"setFatal") {
281 }
else if (prop.
name() ==
"setError") {
283 }
else if (prop.
name() ==
"setWarning") {
285 }
else if (prop.
name() ==
"setInfo") {
287 }
else if (prop.
name() ==
"setDebug") {
289 }
else if (prop.
name() ==
"setVerbose") {
291 }
else if (prop.
name() ==
"setAlways") {
294 cerr <<
"MessageSvc ERROR: Unknown message threshold parameter: "
302 <<
" to a StringArrayProperty (which it should be!)" <<
endl;
306 for ( itr = sap->
value().begin();
307 itr != sap->
value().end();
309 setOutputLevel( *itr, ic );
321 if (prop.
name() ==
"countInactive") {
340 os <<
"Summarizing all message counts" <<
endl;
342 os <<
"Listing sources of suppressed message: " <<
endl;
345 os <<
"=====================================================" <<
endl;
346 os <<
" Message Source | Level | Count" <<
endl;
347 os <<
"-----------------------------+---------+-------------" <<
endl;
353 for (itr=m_sourceMap.
begin(); itr!=m_sourceMap.
end(); ++itr) {
355 if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
356 (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
371 os << itr->second.msg[ic];
379 os <<
"=====================================================" <<
endl;
381 if (found || m_stats) {
387 if (m_inactCount.value()) {
390 os <<
"Listing sources of Unprotected and Unseen messages\n";
396 for (itr=m_inactiveMap.
begin(); itr!=m_inactiveMap.
end(); ++itr) {
398 if (itr->second.msg[ic] != 0) {
399 if (itr->first.length() > ml) { ml = itr->first.length(); }
404 for (
unsigned int i=0;
i<ml+25; ++
i) {
411 os <<
"Message Source";
413 os <<
"| Level | Count" <<
endl;
415 for (
unsigned int i=0;
i<ml+3; ++
i) {
418 os <<
"+---------+-----------" <<
endl;
421 for (itr=m_inactiveMap.
begin(); itr!=m_inactiveMap.
end(); ++itr) {
423 if (itr->second.msg[ic] != 0) {
438 os << itr->second.msg[ic];
446 for (
unsigned int i=0;
i<ml+25; ++
i) {
464 if (itr != m_colMap.end()) {
465 icol = offset + itr->second;
485 boost::recursive_mutex::scoped_lock
lock(m_reportMutex);
494 if ( !m_loggedStreams.empty() ) {
496 if ( m_loggedStreams.end() != iLog ) {
501 if ( m_suppress.value() || m_stats.value() ) {
505 const int nmsg = ++(m_sourceMap[msg.
getSource()].msg[key]);
507 if (m_suppress.value()) {
509 if ( m_msgLimit[key] != 0 ) {
510 if (nmsg == m_msgLimit[key]) {
513 << m_msgLimit[key].value()
515 << msg.
getSource() +
". Suppressing further output.";
518 }
else if (nmsg > m_msgLimit[key]) {
527 if ( first != m_streamMap.end() ) {
529 while( first != last ) {
535 else if ( key >= outputLevel ) {
541 (*m_defaultStream) << m_logColorCodes[key] << *cmsg <<
"\033[m"
546 if (cmsg != &msg) {
delete cmsg; }
557 reportMessage(msg, outputLevel(msg.
getSource()));
568 const char* message) {
570 reportMessage( msg );
583 reportMessage( msg );
596 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
599 if ( first != m_messageMap.end() ) {
601 while( first != last ) {
607 reportMessage( stat_code1 );
608 reportMessage( msg );
613 Message mesg = m_defaultMessage;
618 reportMessage( stat_code2 );
619 reportMessage( mesg );
635 m_streamMap.insert( value_type( key,
NamedStream(name,stream) ) );
647 m_streamMap.erase( m_streamMap.begin(), m_streamMap.end() );
659 m_streamMap.erase( message_type );
676 while( first != last ) {
677 if ( (*first).second.second == stream ) {
678 m_streamMap.erase( first );
700 while( first != m_streamMap.end() ) {
701 if ( (*first).second.second == stream ) {
702 m_streamMap.erase( first );
721 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
724 m_messageMap.insert( value_type( key, msg ) );
736 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
738 m_messageMap.erase( m_messageMap.begin(), m_messageMap.end() );
750 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
752 m_messageMap.erase( key );
764 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
771 while( first != last ) {
772 const Message& message = (*first).second;
773 if ( message == msg ) {
774 m_messageMap.erase( first );
785 return m_outputLevel;
791 boost::recursive_mutex::scoped_lock
lock(m_thresholdMapMutex);
795 it = m_thresholdMap.find( source );
796 if( it != m_thresholdMap.end() ) {
800 return m_outputLevel;
807 m_outputLevel = new_level;
813 boost::recursive_mutex::scoped_lock
lock(m_thresholdMapMutex);
824 m_thresholdMap[source] =
level;
831 return m_logColorCodes[logLevel];
840 return m_msgCount[
level];
848 ++(m_inactiveMap[source].msg[
level]);
857 iLog != m_loggedStreams.end();
861 m_loggedStreams.clear();
864 const StreamMap_t& streamMap = m_loggedStreamsName;
865 typedef StreamMap_t::const_iterator StreamMapIter;
867 for ( StreamMapIter iProp = streamMap.begin(), iEnd = streamMap.end();
875 for ( StreamMapIter jProp = streamMap.begin();
878 if ( jProp->first != iProp->first ) {
879 outFileNames.
insert( jProp->second );
883 tee( sourceName, outFileName, outFileNames );
900 if ( iStream != iEnd ) {
901 delete iStream->second;
903 m_loggedStreams.erase( iStream );
908 iEnd = m_loggedStreams.end();
909 for ( iStream = m_loggedStreams.begin(); iStream != iEnd; ++iStream ) {
910 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
911 m_loggedStreams[sourceName] = m_loggedStreams[iStream->first];
918 if ( !out->good() ) {
924 m_loggedStreams[sourceName] = out;