26 template <
typename Container,
typename Iterator,
typename Predicate>
28 while ( first != last ) {
30 first = c.erase( first );
36 template <
typename Container,
typename Predicate>
37 void erase_if( Container& c, Predicate pred ) {
41 template <
typename Container,
typename Iterator,
typename Predicate>
43 return erase_if( c,
std::move( range.first ),
std::move( range.second ), std::forward<Predicate>( pred ) );
50 else if ( col ==
"red" )
52 else if ( col ==
"green" )
54 else if ( col ==
"yellow" )
56 else if ( col ==
"blue" )
58 else if ( col ==
"purple" )
60 else if ( col ==
"cyan" )
62 else if ( col ==
"white" )
74 static const
std::
string levelNames[
MSG::
NUM_LEVELS] = {
"NIL",
"VERBOSE",
"DEBUG",
"INFO",
75 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
133 if ( pname ==
"fatalColorCode" )
135 else if ( pname ==
"errorColorCode" )
137 else if ( pname ==
"warningColorCode" )
139 else if ( pname ==
"infoColorCode" )
141 else if ( pname ==
"debugColorCode" )
143 else if ( pname ==
"verboseColorCode" )
145 else if ( pname ==
"alwaysColorCode" )
155 if ( col_desc.size() == 1 ) {
157 if ( desc.
empty() ) {
159 }
else if ( desc[0] ==
'[' ) {
160 code =
"\033" + desc;
162 code =
"\033[" + colTrans( desc, 90 ) +
";1m";
164 }
else if ( col_desc.size() == 2 ) {
165 code =
"\033[" + colTrans( col_desc[0], 90 ) +
";" + colTrans( col_desc[1], 100 ) +
";1m";
174 if ( prop.
name() ==
"alwaysLimit" ) {
176 if ( p && p->
value() != 0 ) {
180 }
else if ( prop.
name() ==
"defaultLimit" ) {
184 }
else if ( prop.
name() !=
"fatalLimit" && prop.
name() !=
"errorLimit" && prop.
name() !=
"warningLimit" &&
185 prop.
name() ==
"infoLimit" && prop.
name() ==
"debugLimit" && prop.
name() ==
"verboseLimit" ) {
213 <<
" to a Gaudi::Property<std::vector<std::string>> (which it should be!)" <<
std::endl;
225 if ( prop.
name() ==
"countInactive" ) {
242 os <<
"Summarizing all message counts" <<
std::endl;
244 os <<
"Listing sources of suppressed message: " <<
std::endl;
247 os <<
"=====================================================" <<
std::endl;
248 os <<
" Message Source | Level | Count" <<
std::endl;
249 os <<
"-----------------------------+---------+-------------" <<
std::endl;
259 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
264 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
265 os << levelNames[ic];
269 os << itr->second.msg[ic];
276 os <<
"=====================================================" <<
std::endl;
284 os <<
"Listing sources of Unprotected and Unseen messages\n";
288 unsigned int ml( 0 );
291 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) { ml = itr.first.length(); }
295 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
299 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
300 os <<
"Message Source";
304 for (
unsigned int i = 0; i < ml + 3; ++i ) os <<
"-";
305 os <<
"+---------+-----------" <<
std::endl;
307 for (
auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
309 if ( itr->second.msg[ic] != 0 ) {
312 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
318 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
319 os << levelNames[ic];
324 os << itr->second.msg[ic];
332 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 ) {
delete cmsg; }
441 auto report = [&](
Message mesg ) {
442 mesg.setSource( source );
450 std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
495 [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
508 erase_if(
m_streamMap, [&]( StreamMap::const_reference j ) {
return j.second.second == stream; } );
559 [&]( MessageMap::const_reference j ) {
return j.second ==
msg; } );
591 }
else if ( i->second != level ) {
626 for (
auto& jProp : m_loggedStreamsName ) {
627 if ( jProp.first != iProp.first ) { outFileNames.
insert( jProp.second ); }
629 tee( iProp.first, iProp.second, outFileNames );
637 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
645 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
646 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
651 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
652 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.
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.
constexpr static const auto SUCCESS
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.
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
constexpr static const auto FAILURE
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 (.