26 template <
typename Container,
typename Iterator,
typename Predicate >
28 while ( first!=last ) {
29 if ( pred(*first) ) first = c.erase(first);
34 template<
typename Container,
typename Predicate >
35 void erase_if( Container& c, Predicate pred ) {
37 std::forward<Predicate>(pred) );
40 template<
typename Container,
typename Iterator,
typename Predicate >
43 std::forward<Predicate>(pred) );
53 "NIL",
"VERBOSE",
"DEBUG",
"INFO",
54 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"
85 const int defaultLimit = 500;
99 "for each message source specified, print a stack trace for"
100 "the unprotected and unseen messages" );
108 "MessageStream sources we want to dump into a logfile" );
173 for (
const auto& p : tbl ) {
175 if (lC.value().empty()) {
210 return prop.
name() == t.first;
213 std::cout <<
"ERROR: Unknown message color parameter: " << prop.
name()
226 }
else if (itr->compare(0,1,
"[") == 0) {
227 code =
"\033" + *itr;
229 code =
"\033[" +
colTrans(*itr, 90) +
";1m";
235 code =
"\033[" +
colTrans(*itr, 90) +
";"
247 if (prop.
name() ==
"alwaysLimit") {
249 if (p && p->
value() != 0) {
253 }
else if (prop.
name() ==
"defaultLimit") {
259 }
else if (prop.
name() !=
"fatalLimit" &&
260 prop.
name() !=
"errorLimit" &&
261 prop.
name() !=
"warningLimit" &&
262 prop.
name() ==
"infoLimit" &&
263 prop.
name() ==
"debugLimit" &&
264 prop.
name() ==
"verboseLimit") {
265 std::cout <<
"MessageSvc ERROR: Unknown message limit parameter: "
285 return prop.
name() == t.first;
288 std::cerr <<
"MessageSvc ERROR: Unknown message threshold parameter: "
297 <<
" to a StringArrayProperty (which it should be!)" <<
std::endl;
310 if (prop.
name() ==
"countInactive") {
329 os <<
"Summarizing all message counts" <<
std::endl;
331 os <<
"Listing sources of suppressed message: " <<
std::endl;
334 os <<
"=====================================================" <<
std::endl;
335 os <<
" Message Source | Level | Count" <<
std::endl;
336 os <<
"-----------------------------+---------+-------------" <<
std::endl;
347 os.
setf(std::ios_base::left,std::ios_base::adjustfield);
352 os.
setf(std::ios_base::right,std::ios_base::adjustfield);
353 os << levelNames[ic];
357 os << itr->second.msg[ic];
364 os <<
"=====================================================" <<
std::endl;
372 os <<
"Listing sources of Unprotected and Unseen messages\n";
379 if (itr.second.msg[ic] != 0 && itr.first.length() > ml) {
380 ml = itr.first.length();
385 for (
unsigned int i=0;
i<ml+25; ++
i) os <<
"=";
389 os.
setf(std::ios_base::left,std::ios_base::adjustfield);
390 os <<
"Message Source";
394 for (
unsigned int i=0;
i<ml+3; ++
i) os <<
"-";
395 os <<
"+---------+-----------" <<
std::endl;
398 for (
auto itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
400 if (itr->second.msg[ic] != 0) {
403 os.
setf(std::ios_base::left,std::ios_base::adjustfield);
409 os.
setf(std::ios_base::right,std::ios_base::adjustfield);
410 os << levelNames[ic];
415 os << itr->second.msg[ic];
423 for (
unsigned int i=0;
i<ml+25; ++
i) os <<
"=";
436 int icol = offset + ( (itr !=
m_colMap.
end()) ? itr->second : 8 );
475 std::string txt = levelNames[key] +
" message limit ("
477 +
") reached for " + msg.
getSource() +
". Suppressing further output.";
487 *sm.second.second << *cmsg << std::endl;
489 }
else if ( key >= outputLevel ) {
500 if (cmsg != &msg) {
delete cmsg; }
522 const char* message) {
555 auto report = [&](
Message mesg) {
556 mesg.setSource( source );
565 [&](MessageMap::const_reference sm) { report(sm.second); } );
619 [&](StreamMap::const_reference j)
620 {
return j.second.second == stream; } );
633 erase_if(
m_streamMap, [&](StreamMap::const_reference j)
634 {
return j.second.second == stream; } );
689 [&](MessageMap::const_reference j) {
return j.second==
msg; } ) ;
721 }
else if (
i->second!=level) {
747 std::cout <<
"== inactive message detected from "
764 for (
auto& jProp : m_loggedStreamsName ) {
765 if ( jProp.first != iProp.first ) {
766 outFileNames.
insert( jProp.second );
769 tee( iProp.first, iProp.second, outFileNames );
779 const std::ios_base::openmode openMode = std::ios_base::out |
780 std::ios_base::trunc;
790 if ( outFileNames.
find( outFileName ) != outFileNames.
end() ) {
791 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
796 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
797 if ( out->good() ) m_loggedStreams[sourceName] =
std::move(out);
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
const std::string & getFormat() const
Get the format string.
std::string colTrans(std::string, int)
StatusCode initialize() override
IntegerProperty m_outputLevel
Service output level.
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
std::ostream * m_defaultStream
Pointer to the output stream.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Gaudi::StateMachine::State m_state
Service state.
StreamMap m_streamMap
Stream map.
std::array< int, MSG::NUM_LEVELS > m_msgCount
unsigned long getCode() const
Get the status code by value.
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
const std::string & name() const
property name
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Message m_defaultMessage
Default Message.
MessageMap m_messageMap
Message map.
void setupLimits(Property &prop)
void setupInactCount(Property &prop)
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
MessageSvc(const std::string &name, ISvcLocator *svcloc)
bool set(const TYPE &value)
update the value of the property/check the verifier
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.
std::pair< std::string, std::ostream * > NamedStream
void eraseMessage() override
bool isFailure() const
Test for a status code of FAILURE.
GAUDI_API int backTrace(void **addresses, const int depth)
#define DECLARE_COMPONENT(type)
UnsignedIntegerProperty m_statLevel
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
std::map< std::string, MsgAry > m_sourceMap
std::string getLogColor(int logLevel) const override
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.
static const std::string getDefaultTimeFormat()
Get the default time format string.
This class is used for returning status codes from appropriate routines.
static const std::string getDefaultFormat()
Get the default format string.
void reportMessage(const Message &message) override
auto end(reverse_wrapper< T > &w)
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
const TYPE & value() const
explicit conversion
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
StringArrayProperty m_thresholdProp[MSG::NUM_LEVELS]
Properties controlling.
void setFormat(std::string msg) const
Set the format string.
Property base class allowing Property* collections to be "homogeneous".
StatusCode finalize() override
Finalize Service.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
std::string m_defaultFormat
Default format for the messages.
Print levels enumeration.
void setTimeFormat(std::string timeFormat) const
Set the time format string.
void setupColors(Property &prop)
std::map< std::string, MsgAry > m_inactiveMap
void initColors(Property &prop)
std::string m_logColorCodes[MSG::NUM_LEVELS]
const std::string & getSource() const
Get the message source.
int messageCount(MSG::Level logLevel) const override
BooleanProperty m_inactCount
int outputLevel() const override
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
std::map< std::string, std::string > m_loggedStreamsName
std::vector< std::string > m_tracedInactiveSources
void insertMessage(const StatusCode &code, const Message &message) override
BooleanProperty m_suppress
void setupThreshold(Property &prop)
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
void insertStream(int message_type, const std::string &name, std::ostream *stream) override
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.