Go to the documentation of this file.
36 template <
typename Container,
typename Iterator,
typename Predicate>
38 while ( first != last ) {
40 first =
c.erase( first );
46 template <
typename Container,
typename Predicate>
47 void erase_if( Container&
c, Predicate pred ) {
51 template <
typename Container,
typename Iterator,
typename Predicate>
56 std::string colTrans( std::string_view col,
int offset ) {
79 "WARNING",
"ERROR",
"FATAL",
"ALWAYS"};
86 if (
app )
app->outputLevelUpdate();
141 :
pname ==
"errorColorCode"
143 :
pname ==
"warningColorCode"
145 :
pname ==
"infoColorCode"
147 :
pname ==
"debugColorCode"
149 :
pname ==
"verboseColorCode"
151 :
pname ==
"alwaysColorCode"
154 "ERROR: Unknown message color parameter: " +
pname,
162 if ( col_desc.size() == 1 ) {
164 if ( desc.
empty() ) {
166 }
else if ( desc[0] ==
'[' ) {
167 code =
"\033" + desc;
169 code =
"\033[" + colTrans( desc, 90 ) +
";1m";
171 }
else if ( col_desc.size() == 2 ) {
172 code =
"\033[" + colTrans( col_desc[0], 90 ) +
";" + colTrans( col_desc[1], 100 ) +
";1m";
181 if ( prop.
name() ==
"alwaysLimit" ) {
183 if ( p && p->
value() != 0 ) {
187 }
else if ( prop.
name() ==
"defaultLimit" ) {
191 }
else if ( prop.
name() !=
"fatalLimit" && prop.
name() !=
"errorLimit" && prop.
name() !=
"warningLimit" &&
192 prop.
name() ==
"infoLimit" && prop.
name() ==
"debugLimit" && prop.
name() ==
"verboseLimit" ) {
220 <<
" to a Gaudi::Property<std::vector<std::string>> (which it should be!)" <<
std::endl;
232 if ( prop.
name() ==
"countInactive" ) {
249 os <<
"Summarizing all message counts" <<
std::endl;
251 os <<
"Listing sources of suppressed message: " <<
std::endl;
254 os <<
"=====================================================" <<
std::endl;
255 os <<
" Message Source | Level | Count" <<
std::endl;
256 os <<
"-----------------------------+---------+-------------" <<
std::endl;
266 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
271 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
272 os << levelNames[ic];
276 os << itr->second.msg[ic];
283 os <<
"=====================================================" <<
std::endl;
291 os <<
"Listing sources of Unprotected and Unseen messages\n";
295 unsigned int ml( 0 );
298 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) { ml = itr.first.length(); }
302 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
306 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
307 os <<
"Message Source";
311 for (
unsigned int i = 0; i < ml + 3; ++i ) os <<
"-";
312 os <<
"+---------+-----------" <<
std::endl;
316 if ( itr->second.msg[ic] != 0 ) {
319 os.
setf( std::ios_base::left, std::ios_base::adjustfield );
325 os.
setf( std::ios_base::right, std::ios_base::adjustfield );
326 os << levelNames[ic];
331 os << itr->second.msg[ic];
339 for (
unsigned int i = 0; i < ml + 25; ++i ) os <<
"=";
383 ") reached for " +
msg.getSource() +
". Suppressing further output.";
393 [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
404 if ( cmsg != &
msg ) {
delete cmsg; }
438 auto report = [&](
Message mesg ) {
439 mesg.setSource( source );
492 [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
505 erase_if(
m_streamMap, [&]( StreamMap::const_reference j ) {
return j.second.second ==
stream; } );
556 [&]( MessageMap::const_reference j ) { return j.second == msg; } );
588 }
else if ( i->second !=
level ) {
606 ++entry->second.msg[
level];
610 std::cout <<
"== inactive message detected from " << source <<
" ==\n";
627 [](
const auto& p ) -> std::string_view { return p.second; } );
631 []( std::string_view fname ) {
632 return std::pair{fname, std::make_shared<std::ofstream>(
633 std::string{fname}, std::ios_base::out | std::ios_base::trunc )};
636 for (
auto& iProp : m_loggedStreamsName ) {
637 auto&
stream = outStreams.at( iProp.second );
638 if (
stream->good() ) m_loggedStreams.emplace( iProp.first,
stream );
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
const std::string name() const
property name
StatusCode reinitialize() override
Reinitialize Service.
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
StatusCode initialize() override
void setupLimits(Gaudi::Details::PropertyBase &prop)
Gaudi::Property< bool > m_stats
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Gaudi::StateMachine::State m_state
Service state
Private helper class to keep the count of messages of a type (MSG::LEVEL).
Gaudi::Property< std::string > m_defaultTimeFormat
void insertMessage(const StatusCode &code, Message message) override
void incrInactiveCount(MSG::Level level, std::string_view src) override
void reportMessage(const Message &message) override
std::string m_logColorCodes[MSG::NUM_LEVELS]
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
int messageCount(MSG::Level logLevel) const override
GAUDI_API int backTrace(void **addresses, const int depth)
bool setValue(const ValueType &v)
StreamMap m_streamMap
Stream map.
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Gaudi::Property< unsigned int > m_statLevel
const std::string & name() const override
Retrieve name of the service
double * begin(CLHEP::HepVector &v)
std::map< std::string, MsgAry, std::less<> > m_sourceMap
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
std::array< int, MSG::NUM_LEVELS > m_msgCount
const ValueType & value() const
Backward compatibility (.
void setFormat(std::string msg) const
Set the format string.
Message m_defaultMessage
Default Message.
ThresholdMap m_thresholdMap
Output level threshold map.
MessageMap m_messageMap
Message map.
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
std::map< std::string, MsgAry, std::less<> > m_inactiveMap
int outputLevel() const override
StatusCode finalize() override
Finalize Service.
Gaudi::Property< bool > m_inactCount
constexpr static const auto SUCCESS
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
std::pair< std::string, std::ostream * > NamedStream
Gaudi::Property< std::map< std::string, std::string, std::less<> > > m_loggedStreamsName
void setupInactCount(Gaudi::Details::PropertyBase &prop)
#define DECLARE_COMPONENT(type)
void eraseMessage() override
Gaudi::Property< bool > m_color
code_t getCode() const
Retrieve value ("checks" the StatusCode)
std::map< std::string, std::shared_ptr< std::ostream >, std::less<> > m_loggedStreams
StatusCode initialize() override
Initialize Service.
std::string getLogColor(int logLevel) const override
constexpr static const auto FAILURE
void eraseStream() override
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
MessageSvc(const std::string &name, ISvcLocator *svcloc)
Gaudi::Property< bool > m_suppress
void insertStream(int message_type, std::string name, std::ostream *stream) override
Gaudi::Property< std::string > m_defaultFormat
void setOutputLevel(int new_level) override
Gaudi::Property< int > m_outputLevel
flag indicating whether ToolHandle tools have been added to m_tools
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
void setupColors(Gaudi::Details::PropertyBase &prop)