33 declareProperty(
"showStats", m_stats =
false );
34 declareProperty(
"statLevel", m_statLevel = 0 );
37 declareProperty(
"setVerbose", m_thresholdProp[
MSG::VERBOSE] );
38 declareProperty(
"setDebug", m_thresholdProp[
MSG::DEBUG] );
39 declareProperty(
"setInfo", m_thresholdProp[
MSG::INFO] );
40 declareProperty(
"setWarning", m_thresholdProp[
MSG::WARNING] );
41 declareProperty(
"setError", m_thresholdProp[
MSG::ERROR] );
42 declareProperty(
"setFatal", m_thresholdProp[
MSG::FATAL] );
43 declareProperty(
"setAlways", m_thresholdProp[
MSG::ALWAYS] );
45 declareProperty(
"useColors", m_color=
false);
48 declareProperty(
"fatalColorCode", m_logColors[MSG::FATAL] );
49 declareProperty(
"errorColorCode", m_logColors[MSG::ERROR] );
50 declareProperty(
"warningColorCode", m_logColors[MSG::WARNING] );
51 declareProperty(
"infoColorCode", m_logColors[MSG::INFO] );
52 declareProperty(
"debugColorCode", m_logColors[MSG::DEBUG] );
53 declareProperty(
"verboseColorCode", m_logColors[MSG::VERBOSE] );
54 declareProperty(
"alwaysColorCode", m_logColors[MSG::ALWAYS] );
56 const int defaultLimit = 500;
57 declareProperty(
"fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
58 declareProperty(
"errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
59 declareProperty(
"warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
60 declareProperty(
"infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
61 declareProperty(
"debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
62 declareProperty(
"verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
63 declareProperty(
"alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
65 declareProperty(
"defaultLimit", m_msgLimit[
MSG::NIL] = defaultLimit );
67 declareProperty(
"enableSuppression", m_suppress =
false );
74 declareProperty(
"loggedStreams",
76 "MessageStream sources we want to dump into a logfile" );
106 for ( ; iStream != endStream; ++iStream ) {
107 delete iStream->second;
124 sc = setProperties();
158 if (m_color ==
true) {
160 if (m_logColors[
MSG::FATAL].value().size() == 0) {
168 if (m_logColors[
MSG::ERROR].value().size() == 0) {
189 m_logColors[ic].set( def );
200 if (! m_color)
return;
203 if (prop.
name() ==
"fatalColorCode") {
205 }
else if (prop.
name() ==
"errorColorCode") {
207 }
else if (prop.
name() ==
"warningColorCode") {
209 }
else if (prop.
name() ==
"infoColorCode") {
211 }
else if (prop.
name() ==
"debugColorCode") {
213 }
else if (prop.
name() ==
"verboseColorCode") {
215 }
else if (prop.
name() ==
"alwaysColorCode") {
218 cout <<
"ERROR: Unknown message color parameter: " << prop.
name()
225 itr = m_logColors[ic].value().
begin();
227 if ( m_logColors[ic].value().size() == 1 ) {
231 }
else if (itr->substr(0,1) ==
"[") {
232 code =
"\033" + *itr;
234 code =
"\033[" + colTrans(*itr, 90) +
";1m";
237 }
else if (m_logColors[ic].value().size() == 2) {
240 code =
"\033[" + colTrans(*itr, 90) +
";"
241 + colTrans(*itr2, 100) +
";1m";
245 m_logColorCodes[ic] = code;
252 if (prop.
name() ==
"alwaysLimit") {
254 if (p && p->
value() != 0) {
255 cout <<
"MessageSvc ERROR: cannot suppress ALWAYS messages" <<
endl;
258 }
else if (prop.
name() ==
"defaultLimit") {
261 m_msgLimit[
i] = m_msgLimit[
MSG::NIL].value();
264 }
else if (prop.
name() !=
"fatalLimit" &&
265 prop.
name() !=
"errorLimit" &&
266 prop.
name() !=
"warningLimit" &&
267 prop.
name() ==
"infoLimit" &&
268 prop.
name() ==
"debugLimit" &&
269 prop.
name() ==
"verboseLimit") {
270 cout <<
"MessageSvc ERROR: Unknown message limit parameter: "
280 if (prop.
name() ==
"setFatal") {
282 }
else if (prop.
name() ==
"setError") {
284 }
else if (prop.
name() ==
"setWarning") {
286 }
else if (prop.
name() ==
"setInfo") {
288 }
else if (prop.
name() ==
"setDebug") {
290 }
else if (prop.
name() ==
"setVerbose") {
292 }
else if (prop.
name() ==
"setAlways") {
295 cerr <<
"MessageSvc ERROR: Unknown message threshold parameter: "
303 <<
" to a StringArrayProperty (which it should be!)" <<
endl;
307 for ( itr = sap->
value().begin();
308 itr != sap->
value().end();
310 setOutputLevel( *itr, ic );
322 if (prop.
name() ==
"countInactive") {
341 os <<
"Summarizing all message counts" <<
endl;
343 os <<
"Listing sources of suppressed message: " <<
endl;
346 os <<
"=====================================================" <<
endl;
347 os <<
" Message Source | Level | Count" <<
endl;
348 os <<
"-----------------------------+---------+-------------" <<
endl;
354 for (itr=m_sourceMap.
begin(); itr!=m_sourceMap.
end(); ++itr) {
356 if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
357 (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
372 os << itr->second.msg[ic];
380 os <<
"=====================================================" <<
endl;
382 if (found || m_stats) {
388 if (m_inactCount.value()) {
391 os <<
"Listing sources of Unprotected and Unseen messages\n";
397 for (itr=m_inactiveMap.
begin(); itr!=m_inactiveMap.
end(); ++itr) {
399 if (itr->second.msg[ic] != 0) {
400 if (itr->first.length() > ml) { ml = itr->first.length(); }
405 for (
unsigned int i=0;
i<ml+25; ++
i) {
412 os <<
"Message Source";
414 os <<
"| Level | Count" <<
endl;
416 for (
unsigned int i=0;
i<ml+3; ++
i) {
419 os <<
"+---------+-----------" <<
endl;
422 for (itr=m_inactiveMap.
begin(); itr!=m_inactiveMap.
end(); ++itr) {
424 if (itr->second.msg[ic] != 0) {
439 os << itr->second.msg[ic];
447 for (
unsigned int i=0;
i<ml+25; ++
i) {
465 if (itr != m_colMap.end()) {
466 icol = offset + itr->second;
486 boost::recursive_mutex::scoped_lock
lock(m_reportMutex);
495 if ( !m_loggedStreams.empty() ) {
497 if ( m_loggedStreams.end() != iLog ) {
502 if ( m_suppress.value() || m_stats.value() ) {
506 const int nmsg = ++(m_sourceMap[msg.
getSource()].msg[key]);
508 if (m_suppress.value()) {
510 if ( m_msgLimit[key] != 0 ) {
511 if (nmsg == m_msgLimit[key]) {
514 << m_msgLimit[key].value()
516 << msg.
getSource() +
". Suppressing further output.";
519 }
else if (nmsg > m_msgLimit[key]) {
528 if ( first != m_streamMap.end() ) {
530 while( first != last ) {
536 else if ( key >= outputLevel ) {
542 (*m_defaultStream) << m_logColorCodes[key] << *cmsg <<
"\033[m"
547 if (cmsg != &msg) {
delete cmsg; }
558 reportMessage(msg, outputLevel(msg.
getSource()));
569 const char* message) {
571 reportMessage( msg );
584 reportMessage( msg );
597 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
600 if ( first != m_messageMap.end() ) {
602 while( first != last ) {
608 reportMessage( stat_code1 );
609 reportMessage( msg );
614 Message mesg = m_defaultMessage;
619 reportMessage( stat_code2 );
620 reportMessage( mesg );
636 m_streamMap.insert( value_type( key,
NamedStream(name,stream) ) );
648 m_streamMap.erase( m_streamMap.begin(), m_streamMap.end() );
660 m_streamMap.erase( message_type );
677 while( first != last ) {
678 if ( (*first).second.second == stream ) {
679 m_streamMap.erase( first );
701 while( first != m_streamMap.end() ) {
702 if ( (*first).second.second == stream ) {
703 m_streamMap.erase( first );
722 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
725 m_messageMap.insert( value_type( key, msg ) );
737 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
739 m_messageMap.erase( m_messageMap.begin(), m_messageMap.end() );
751 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
753 m_messageMap.erase( key );
765 boost::recursive_mutex::scoped_lock
lock(m_messageMapMutex);
772 while( first != last ) {
773 const Message& message = (*first).second;
774 if ( message == msg ) {
775 m_messageMap.erase( first );
786 return m_outputLevel;
792 boost::recursive_mutex::scoped_lock
lock(m_thresholdMapMutex);
796 it = m_thresholdMap.find( source );
797 if( it != m_thresholdMap.end() ) {
801 return m_outputLevel;
808 m_outputLevel = new_level;
814 boost::recursive_mutex::scoped_lock
lock(m_thresholdMapMutex);
825 m_thresholdMap[source] =
level;
832 return m_logColorCodes[logLevel];
841 return m_msgCount[
level];
849 ++(m_inactiveMap[source].msg[
level]);
858 iLog != m_loggedStreams.end();
862 m_loggedStreams.clear();
865 const StreamMap_t& streamMap = m_loggedStreamsName;
866 typedef StreamMap_t::const_iterator StreamMapIter;
868 for ( StreamMapIter iProp = streamMap.begin(), iEnd = streamMap.end();
876 for ( StreamMapIter jProp = streamMap.begin();
879 if ( jProp->first != iProp->first ) {
880 outFileNames.
insert( jProp->second );
884 tee( sourceName, outFileName, outFileNames );
901 if ( iStream != iEnd ) {
902 delete iStream->second;
904 m_loggedStreams.erase( iStream );
909 iEnd = m_loggedStreams.end();
910 for ( iStream = m_loggedStreams.begin(); iStream != iEnd; ++iStream ) {
911 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
912 m_loggedStreams[sourceName] = m_loggedStreams[iStream->first];
919 if ( !out->good() ) {
925 m_loggedStreams[sourceName] = out;