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 ) );
54 static const
std::
string levelNames[
MSG::
NUM_LEVELS] = {
"NIL",
"VERBOSE",
"DEBUG",
"INFO",
55 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
133 for (
const auto& p : tbl ) {
135 if ( lC.value().empty() ) {
179 if ( itr->empty() ) {
181 }
else if ( itr->compare( 0, 1,
"[" ) == 0 ) {
182 code =
"\033" + *itr;
184 code =
"\033[" +
colTrans( *itr, 90 ) +
";1m";
187 }
else if (
m_logColors[ic].value().size() == 2 ) {
190 code =
"\033[" +
colTrans( *itr, 90 ) +
";" +
colTrans( *itr2, 100 ) +
";1m";
200 if ( prop.
name() ==
"alwaysLimit" ) {
202 if ( p && p->
value() != 0 ) {
206 }
else if ( prop.
name() ==
"defaultLimit" ) {
212 }
else if ( prop.
name() !=
"fatalLimit" && prop.
name() !=
"errorLimit" && prop.
name() !=
"warningLimit" &&
213 prop.
name() ==
"infoLimit" && prop.
name() ==
"debugLimit" && prop.
name() ==
"verboseLimit" ) {
242 <<
" to a Gaudi::Property<std::vector<std::string>> (which it should be!)" <<
std::endl;
255 if ( prop.
name() ==
"countInactive" ) {
273 os <<
"Summarizing all message counts" <<
std::endl;
275 os <<
"Listing sources of suppressed message: " <<
std::endl;
278 os <<
"=====================================================" <<
std::endl;
279 os <<
" Message Source | Level | Count" <<
std::endl;
280 os <<
"-----------------------------+---------+-------------" <<
std::endl;
290 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
295 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
296 os << levelNames[ic];
300 os << itr->second.msg[ic];
307 os <<
"=====================================================" <<
std::endl;
315 os <<
"Listing sources of Unprotected and Unseen messages\n";
319 unsigned int ml( 0 );
322 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) {
323 ml = itr.first.length();
328 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
332 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
333 os <<
"Message Source";
337 for (
unsigned int i = 0; i < ml + 3; ++i ) os <<
"-";
338 os <<
"+---------+-----------" <<
std::endl;
340 for (
auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
342 if ( itr->second.msg[ic] != 0 ) {
345 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
351 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
352 os << levelNames[ic];
357 os << itr->second.msg[ic];
365 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
379 int icol = offset + ( ( itr !=
m_colMap.
end() ) ? itr->second : 8 );
421 ") reached for " + msg.
getSource() +
". Suppressing further output.";
431 [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
432 }
else if ( key >= outputLevel ) {
442 if ( cmsg != &msg ) {
492 auto report = [&](
Message mesg ) {
493 mesg.setSource( source );
548 [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
562 erase_if(
m_streamMap, [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
617 [&]( MessageMap::const_reference j ) {
return j.second ==
msg; } );
653 }
else if ( i->second != level ) {
691 for (
auto& jProp : m_loggedStreamsName ) {
692 if ( jProp.first != iProp.first ) {
693 outFileNames.
insert( jProp.second );
696 tee( iProp.first, iProp.second, outFileNames );
705 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
715 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
716 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
721 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
722 if ( out->good() ) m_loggedStreams[sourceName] =
std::move( out );
Gaudi::Property< int > m_outputLevel
const std::string & getFormat() const
Get the format string.
std::string colTrans(std::string, int)
StatusCode initialize() override
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
bool setValue(const ValueType &v)
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
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.
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
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.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
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 initColors(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 (.