27 template <
typename Container,
typename Iterator,
typename Predicate>
30 while ( first != last ) {
32 first = c.erase( first );
38 template <
typename Container,
typename Predicate>
39 void erase_if( Container& c, Predicate pred )
44 template <
typename Container,
typename Iterator,
typename Predicate>
47 return erase_if( c,
std::move( range.first ),
std::move( range.second ), std::forward<Predicate>( pred ) );
55 else if ( col ==
"red" )
57 else if ( col ==
"green" )
59 else if ( col ==
"yellow" )
61 else if ( col ==
"blue" )
63 else if ( col ==
"purple" )
65 else if ( col ==
"cyan" )
67 else if ( col ==
"white" )
79 static const
std::
string levelNames[
MSG::
NUM_LEVELS] = {
"NIL",
"VERBOSE",
"DEBUG",
"INFO",
80 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
143 if ( pname ==
"fatalColorCode" )
145 else if ( pname ==
"errorColorCode" )
147 else if ( pname ==
"warningColorCode" )
149 else if ( pname ==
"infoColorCode" )
151 else if ( pname ==
"debugColorCode" )
153 else if ( pname ==
"verboseColorCode" )
155 else if ( pname ==
"alwaysColorCode" )
165 if ( col_desc.size() == 1 ) {
167 if ( desc.
empty() ) {
169 }
else if ( desc[0] ==
'[' ) {
170 code =
"\033" + desc;
172 code =
"\033[" + colTrans( desc, 90 ) +
";1m";
174 }
else if ( col_desc.size() == 2 ) {
175 code =
"\033[" + colTrans( col_desc[0], 90 ) +
";" + colTrans( col_desc[1], 100 ) +
";1m";
185 if ( prop.
name() ==
"alwaysLimit" ) {
187 if ( p && p->
value() != 0 ) {
191 }
else if ( prop.
name() ==
"defaultLimit" ) {
197 }
else if ( prop.
name() !=
"fatalLimit" && prop.
name() !=
"errorLimit" && prop.
name() !=
"warningLimit" &&
198 prop.
name() ==
"infoLimit" && prop.
name() ==
"debugLimit" && prop.
name() ==
"verboseLimit" ) {
227 <<
" to a Gaudi::Property<std::vector<std::string>> (which it should be!)" <<
std::endl;
240 if ( prop.
name() ==
"countInactive" ) {
258 os <<
"Summarizing all message counts" <<
std::endl;
260 os <<
"Listing sources of suppressed message: " <<
std::endl;
263 os <<
"=====================================================" <<
std::endl;
264 os <<
" Message Source | Level | Count" <<
std::endl;
265 os <<
"-----------------------------+---------+-------------" <<
std::endl;
275 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
280 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
281 os << levelNames[ic];
285 os << itr->second.msg[ic];
292 os <<
"=====================================================" <<
std::endl;
300 os <<
"Listing sources of Unprotected and Unseen messages\n";
304 unsigned int ml( 0 );
307 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) {
308 ml = itr.first.length();
313 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
317 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
318 os <<
"Message Source";
322 for (
unsigned int i = 0; i < ml + 3; ++i ) os <<
"-";
323 os <<
"+---------+-----------" <<
std::endl;
325 for (
auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
327 if ( itr->second.msg[ic] != 0 ) {
330 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
336 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
337 os << levelNames[ic];
342 os << itr->second.msg[ic];
350 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
398 ") reached for " + msg.
getSource() +
". Suppressing further output.";
408 [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
409 }
else if ( key >= outputLevel ) {
419 if ( cmsg != &msg ) {
469 auto report = [&](
Message mesg ) {
470 mesg.setSource( source );
478 std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
525 [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
539 erase_if(
m_streamMap, [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
594 [&]( MessageMap::const_reference j ) {
return j.second ==
msg; } );
630 }
else if ( i->second != level ) {
668 for (
auto& jProp : m_loggedStreamsName ) {
669 if ( jProp.first != iProp.first ) {
670 outFileNames.
insert( jProp.second );
673 tee( iProp.first, iProp.second, outFileNames );
682 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
692 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
693 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
698 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
699 if ( out->good() ) m_loggedStreams[sourceName] =
std::move( out );
Gaudi::Property< int > m_outputLevel
const std::string & getFormat() const
Get the format string.
constexpr static const auto FAILURE
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.
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
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
GAUDI_API int backTrace(void **addresses, const int depth)
void setupColors(Gaudi::Details::PropertyBase &prop)
virtual void outputLevelUpdate()=0
Function to call to update the outputLevel of the components (after a change in MessageSvc).
void eraseStream() override
#define DECLARE_COMPONENT(type)
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
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
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.
constexpr static const auto SUCCESS
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 (.
code_t getCode() const
Retrieve value ("checks" the StatusCode)
AttribStringParser::Iterator begin(const AttribStringParser &parser)
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 (.