26 template <
typename Container,
typename Iterator,
typename Predicate>
29 while ( first != last ) {
31 first = c.erase( first );
37 template <
typename Container,
typename Predicate>
38 void erase_if( Container& c, Predicate pred )
43 template <
typename Container,
typename Iterator,
typename Predicate>
46 return erase_if( c,
std::move( range.first ),
std::move( range.second ), std::forward<Predicate>( pred ) );
53 if ( col ==
"red" ) icol =
MSG::RED ;
else 56 if ( col ==
"blue" ) icol =
MSG::BLUE ;
else 58 if ( col ==
"cyan" ) icol =
MSG::CYAN ;
else 69 static const
std::
string levelNames[
MSG::
NUM_LEVELS] = {
"NIL",
"VERBOSE",
"DEBUG",
"INFO",
70 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
128 if ( pname ==
"fatalColorCode" ) level =
MSG::FATAL ;
else 129 if ( pname ==
"errorColorCode" ) level =
MSG::ERROR ;
else 130 if ( pname ==
"warningColorCode" ) level =
MSG::WARNING ;
else 131 if ( pname ==
"infoColorCode" ) level =
MSG::INFO ;
else 132 if ( pname ==
"debugColorCode" ) level =
MSG::DEBUG ;
else 133 if ( pname ==
"verboseColorCode" ) level =
MSG::VERBOSE ;
else 134 if ( pname ==
"alwaysColorCode" ) level =
MSG::ALWAYS ;
else {
135 throw GaudiException(
"ERROR: Unknown message color parameter: " + pname,
143 if ( col_desc.size() == 1 ) {
145 if ( desc.
empty() ) {
147 }
else if ( desc[0] ==
'[' ) {
148 code =
"\033" + desc;
150 code =
"\033[" + colTrans( desc, 90 ) +
";1m";
152 }
else if ( col_desc.size() == 2 ) {
153 code =
"\033[" + colTrans( col_desc[0], 90 ) +
";" + colTrans( col_desc[1], 100 ) +
";1m";
163 if ( prop.
name() ==
"alwaysLimit" ) {
165 if ( p && p->
value() != 0 ) {
169 }
else if ( prop.
name() ==
"defaultLimit" ) {
175 }
else if ( prop.
name() !=
"fatalLimit" && prop.
name() !=
"errorLimit" && prop.
name() !=
"warningLimit" &&
176 prop.
name() ==
"infoLimit" && prop.
name() ==
"debugLimit" && prop.
name() ==
"verboseLimit" ) {
205 <<
" to a Gaudi::Property<std::vector<std::string>> (which it should be!)" <<
std::endl;
218 if ( prop.
name() ==
"countInactive" ) {
236 os <<
"Summarizing all message counts" <<
std::endl;
238 os <<
"Listing sources of suppressed message: " <<
std::endl;
241 os <<
"=====================================================" <<
std::endl;
242 os <<
" Message Source | Level | Count" <<
std::endl;
243 os <<
"-----------------------------+---------+-------------" <<
std::endl;
253 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
258 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
259 os << levelNames[ic];
263 os << itr->second.msg[ic];
270 os <<
"=====================================================" <<
std::endl;
278 os <<
"Listing sources of Unprotected and Unseen messages\n";
282 unsigned int ml( 0 );
285 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) {
286 ml = itr.first.length();
291 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
295 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
296 os <<
"Message Source";
300 for (
unsigned int i = 0; i < ml + 3; ++i ) os <<
"-";
301 os <<
"+---------+-----------" <<
std::endl;
303 for (
auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
305 if ( itr->second.msg[ic] != 0 ) {
308 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
314 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
315 os << levelNames[ic];
320 os << itr->second.msg[ic];
328 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
376 ") reached for " + msg.
getSource() +
". Suppressing further output.";
386 [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
387 }
else if ( key >= outputLevel ) {
397 if ( cmsg != &msg ) {
447 auto report = [&](
Message mesg ) {
448 mesg.setSource( source );
456 std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
503 [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
517 erase_if(
m_streamMap, [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
572 [&]( MessageMap::const_reference j ) {
return j.second ==
msg; } );
608 }
else if ( i->second != level ) {
646 for (
auto& jProp : m_loggedStreamsName ) {
647 if ( jProp.first != iProp.first ) {
648 outFileNames.
insert( jProp.second );
651 tee( iProp.first, iProp.second, outFileNames );
660 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
670 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
671 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
676 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
677 if ( out->good() ) m_loggedStreams[sourceName] =
std::move( out );
Gaudi::Property< int > m_outputLevel
const std::string & getFormat() const
Get the format string.
StatusCode initialize() override
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
bool setValue(const ValueType &v)
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & name() const override
Retrieve name of the service.
Gaudi::StateMachine::State m_state
Service state.
StreamMap m_streamMap
Stream map.
Implementation of property with value of concrete type.
unsigned long getCode() const
Get the status code by value.
std::string getLogColor(int logLevel) const override
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
void setupInactCount(Gaudi::Details::PropertyBase &prop)
std::map< std::string, MsgAry > m_sourceMap
const std::string name() const
property name
Message m_defaultMessage
Default Message.
std::map< std::string, MsgAry > m_inactiveMap
MessageMap m_messageMap
Message map.
Gaudi::Property< std::string > m_defaultTimeFormat
MessageSvc(const std::string &name, ISvcLocator *svcloc)
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
int getType() const
Get the message type.
StatusCode reinitialize() override
Reinitialize Service.
void eraseMessage() override
bool isFailure() const
Test for a status code of FAILURE.
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
GAUDI_API int backTrace(void **addresses, const int depth)
void setupColors(Gaudi::Details::PropertyBase &prop)
#define DECLARE_COMPONENT(type)
auto begin(reverse_wrapper< T > &w)
void eraseStream() override
void incrInactiveCount(MSG::Level level, const std::string &src) override
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Gaudi::Property< bool > m_inactCount
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Gaudi::Property< unsigned int > m_statLevel
void setOutputLevel(int new_level) override
StatusCode initialize() override
Initialize Service.
ThresholdMap m_thresholdMap
Output level threshold map.
This class is used for returning status codes from appropriate routines.
std::pair< std::string, std::ostream * > NamedStream
void reportMessage(const Message &message) override
Gaudi::Property< bool > m_color
auto end(reverse_wrapper< T > &w)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Gaudi::Property< std::string > m_defaultFormat
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
void setFormat(std::string msg) const
Set the format string.
StatusCode finalize() override
Finalize Service.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Print levels enumeration.
void setTimeFormat(std::string timeFormat) const
Set the time format string.
int outputLevel() const override
void setupLimits(Gaudi::Details::PropertyBase &prop)
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Gaudi::Property< bool > m_stats
std::string m_logColorCodes[MSG::NUM_LEVELS]
const std::string & getSource() const
Get the message source.
std::array< int, MSG::NUM_LEVELS > m_msgCount
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
const ValueType & value() const
Backward compatibility (.
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
Gaudi::Property< bool > m_suppress
void insertMessage(const StatusCode &code, const Message &message) override
Gaudi::Property< std::map< std::string, std::string > > m_loggedStreamsName
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
void insertStream(int message_type, const std::string &name, std::ostream *stream) override
int messageCount(MSG::Level logLevel) const override
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.