| The Gaudi Framework v32r1 (f65d50dc)

Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
MessageSvc Class Reference

`#include <src/MessageSvc/MessageSvc.h>`

Inheritance diagram for MessageSvc:
[legend]
Collaboration diagram for MessageSvc:
[legend]

## Classes
struct | MsgAry
| Private helper class to keep the count of messages of a type (MSG::LEVEL). More...

## Public Types
typedef std::pair< std::string, std::ostream * > | NamedStream
typedef std::multimap< int, NamedStream > | StreamMap
typedef std::multimap< StatusCode, Message > | MessageMap
typedef std::map< std::string, int > | ThresholdMap
Public Types inherited from extends< Service, IMessageSvc, IInactiveMessageCounter >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
using | Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...

## Public Member Functions
| MessageSvc (const std::string &name, ISvcLocator *svcloc)
StatusCode | reinitialize () override
| Reinitialize Service. More...
StatusCode | initialize () override
| Initialize Service. More...
StatusCode | finalize () override
| Finalize Service. More...
void | reportMessage (const Message &message) override
void | reportMessage (const Message &msg, int outputLevel) override
void | reportMessage (const StatusCode &code, const std::string &source="") override
void | reportMessage (const char *source, int type, const char *message) override
void | reportMessage (const std::string &source, int type, const std::string &message) override
void | insertMessage (const StatusCode &code, const Message &message) override
void | eraseMessage () override
void | eraseMessage (const StatusCode &code) override
void | eraseMessage (const StatusCode &code, const Message &message) override
void | insertStream (int message_type, const std::string &name, std::ostream *stream) override
void | eraseStream () override
void | eraseStream (int message_type) override
void | eraseStream (int message_type, std::ostream *stream) override
void | eraseStream (std::ostream *stream) override
std::ostream * | defaultStream () const override
void | setDefaultStream (std::ostream *stream) override
int | outputLevel () const override
int | outputLevel (const std::string &source) const override
void | setOutputLevel (int new_level) override
void | setOutputLevel (const std::string &source, int new_level) override
bool | useColor () const override
std::string | getLogColor (int logLevel) const override
int | messageCount (MSG::Level logLevel) const override
void | incrInactiveCount (MSG::Level level, const std::string &src) override
Public Member Functions inherited from extends< Service, IMessageSvc, IInactiveMessageCounter >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...

## Protected Member Functions
virtual void | i_reportMessage (const Message &msg, int outputLevel)
| Internal implementation of reportMessage(const Message&,int) without lock. More...
virtual void | i_reportMessage (const StatusCode &code, const std::string &source)
| Internal implementation of reportMessage(const StatusCode&,const std::string&) without lock. More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging () const
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Private Member Functions
void | setupColors (Gaudi::Details::PropertyBase &prop)
void | setupLimits (Gaudi::Details::PropertyBase &prop)
void | setupThreshold (Gaudi::Details::PropertyBase &prop)
void | setupInactCount (Gaudi::Details::PropertyBase &prop)
void | setupLogStreams ()
void | tee (const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)

## Private Attributes
Gaudi::Property< std::string > | m_defaultFormat {this, "Format", Message::getDefaultFormat(), ""}
Gaudi::Property< std::string > | m_defaultTimeFormat {this, "timeFormat", Message::getDefaultTimeFormat(), ""}
Gaudi::Property< bool > | m_stats {this, "showStats", false, ""}
Gaudi::Property< unsigned int > | m_statLevel {this, "statLevel", 0, ""}
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > | m_thresholdProp
Gaudi::Property< bool > | m_color {this, "useColors", false, ""}
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > | m_logColors
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > | m_msgLimit
Gaudi::Property< bool > | m_suppress {this, "enableSuppression", false, ""}
Gaudi::Property< bool > | m_inactCount {this, "countInactive", false, &MessageSvc::setupInactCount, ""}
Gaudi::Property< std::vector< std::string > > | m_tracedInactiveSources
Gaudi::Property< std::map< std::string, std::string > > | m_loggedStreamsName
std::ostream * | m_defaultStream = &std::cout
| Pointer to the output stream. More...
Message | m_defaultMessage
| Default Message. More...
StreamMap | m_streamMap
| Stream map. More...
MessageMap | m_messageMap
| Message map. More...
ThresholdMap | m_thresholdMap
| Output level threshold map. More...
std::string | m_logColorCodes [MSG::NUM_LEVELS]
std::map< std::string, MsgAry > | m_sourceMap
std::map< std::string, MsgAry > | m_inactiveMap
std::array< int, MSG::NUM_LEVELS > | m_msgCount
std::map< std::string, std::shared_ptr< std::ostream > > | m_loggedStreams
std::recursive_mutex | m_reportMutex
| Mutex to synchronize multiple threads printing. More...
std::recursive_mutex | m_messageMapMutex
| Mutex to synchronize multiple access to m_messageMap. More...
std::recursive_mutex | m_thresholdMapMutex
| Mutex to synchronize multiple access to m_thresholdMap (. More...

## Additional Inherited Members
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, " unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

Definition at line 30 of file MessageSvc.h.

## Member Typedef Documentation

## ◆ MessageMap

typedef std::multimap<StatusCode, Message> MessageSvc::MessageMap

Definition at line 34 of file MessageSvc.h.

## ◆ NamedStream

typedef std::pair<std::string, std::ostream*> MessageSvc::NamedStream

Definition at line 32 of file MessageSvc.h.

## ◆ StreamMap

typedef std::multimap<int, NamedStream> MessageSvc::StreamMap

Definition at line 33 of file MessageSvc.h.

## ◆ ThresholdMap

typedef std::map<std::string, int> MessageSvc::ThresholdMap

Definition at line 35 of file MessageSvc.h.

## Constructor & Destructor Documentation

## ◆ MessageSvc()

MessageSvc::MessageSvc | ( | const std::string & | name,
|  | ISvcLocator * | svcloc
| ) |  |

Definition at line 78 of file MessageSvc.cpp.

78 : base_class( name, svcloc ) {
79
80 m_outputLevel.declareUpdateHandler( [svcloc]( Gaudi::Details::PropertyBase& ) {
81 SmartIF<IAppMgrUI> app = svcloc;
82 if ( app ) app->outputLevelUpdate();
83 } );
84
85 #ifndef NDEBUG
86 // initialize the MsgStream static flag.
87 MsgStream::enableCountInactive( m_inactCount );
88 #endif
89
90 for ( int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
91 m_logColors[ic].declareUpdateHandler( &MessageSvc::setupColors, this );
92 m_msgLimit[ic].declareUpdateHandler( &MessageSvc::setupLimits, this );
93 m_thresholdProp[ic].declareUpdateHandler( &MessageSvc::setupThreshold, this );
94 }
95
96 m_logColors[MSG::FATAL].set( {"blue", "red"} );
97 m_logColors[MSG::ERROR].set( {"white", "red"} );
98 m_logColors[MSG::WARNING].set( {"yellow"} );
99
100 std::fill( std::begin( m_msgCount ), std::end( m_msgCount ), 0 );
101 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176
SmartIF< IAppMgrUI >
std::end
T end(T... args)
extends< Service, IMessageSvc, IInactiveMessageCounter >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
MessageSvc::setupColors
void setupColors(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:133
IAppMgrUI::outputLevelUpdate
virtual void outputLevelUpdate()=0
Function to call to update the outputLevel of the components (after a change in MessageSvc).
MSG::FATAL
Definition: IMessageSvc.h:15
MessageSvc::m_inactCount
Gaudi::Property< bool > m_inactCount
Definition: MessageSvc.h:165
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MessageSvc::m_logColors
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Definition: MessageSvc.h:146
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
std::begin
T begin(T... args)
MSG::NUM_LEVELS
Definition: IMessageSvc.h:15
MSG::ERROR
Definition: IMessageSvc.h:15
MessageSvc::setupLimits
void setupLimits(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:175
MessageSvc::setupThreshold
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:195
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:194
MessageSvc::m_thresholdProp
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
Definition: MessageSvc.h:135
MSG::WARNING
Definition: IMessageSvc.h:15
std::fill
T fill(T... args)
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:155
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:31

## Member Function Documentation

## ◆ defaultStream()

std::ostream* MessageSvc::defaultStream | ( |  | ) | const
| inline override

Definition at line 90 of file MessageSvc.h.

90 { return m_defaultStream; }
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:176

## ◆ eraseMessage() [1/3]

void MessageSvc::eraseMessage | ( |  | ) |
| override

Definition at line 534 of file MessageSvc.cpp.

534 {
535 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
536 m_messageMap.clear();
537 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:179
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:212
std::lock
T lock(T... args)
std::multimap::clear
T clear(T... args)
std::unique_lock

## ◆ eraseMessage() [2/3]

void MessageSvc::eraseMessage | ( | const StatusCode & | code | ) |
| override

Definition at line 546 of file MessageSvc.cpp.

546 {
547 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
548 m_messageMap.erase( key );
549 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:179
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:212
std::multimap::erase
T erase(T... args)
std::lock
T lock(T... args)
std::unique_lock

## ◆ eraseMessage() [3/3]

void MessageSvc::eraseMessage | ( | const StatusCode & | code,
|  | const Message & | message
| ) |  |
| override

Definition at line 558 of file MessageSvc.cpp.

558 {
559 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
560
561 erase_if( m_messageMap, m_messageMap.equal_range( key ),
562 [&]( MessageMap::const_reference j ) { return j.second == msg; } );
563 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:179
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:212
std::lock
T lock(T... args)
std::unique_lock
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
std::multimap::equal_range
T equal_range(T... args)

## ◆ eraseStream() [1/4]

void MessageSvc::eraseStream | ( |  | ) |
| override

Definition at line 477 of file MessageSvc.cpp.

477 { m_streamMap.clear(); }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178
std::multimap::clear
T clear(T... args)

## ◆ eraseStream() [2/4]

void MessageSvc::eraseStream | ( | int | message_type | ) |
| override

Definition at line 486 of file MessageSvc.cpp.

486 { m_streamMap.erase( message_type ); }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178
std::multimap::erase
T erase(T... args)

## ◆ eraseStream() [3/4]

void MessageSvc::eraseStream | ( | int | message_type,
|  | std::ostream * | stream
| ) |  |
| override

Definition at line 495 of file MessageSvc.cpp.

495 {
496 if ( stream ) {
497 erase_if( m_streamMap, m_streamMap.equal_range( key ),
498 [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
499 }
500 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178
std::multimap::equal_range
T equal_range(T... args)

## ◆ eraseStream() [4/4]

void MessageSvc::eraseStream | ( | std::ostream * | stream | ) |
| override

Definition at line 509 of file MessageSvc.cpp.

509 {
510 if ( stream ) {
511 erase_if( m_streamMap, [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
512 }
513 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178

## ◆ finalize()

StatusCode MessageSvc::finalize | ( |  | ) |
| override

Finalize Service.

Definition at line 237 of file MessageSvc.cpp.

237 {
238
239 m_suppress = false;
240
241 {
242 std::ostringstream os;
243
244 if ( m_stats ) {
245 os << "Summarizing all message counts" << std::endl;
246 } else {
247 os << "Listing sources of suppressed message: " << std::endl;
248 }
249
250 os << "=====================================================" << std::endl;
251 os << " Message Source | Level | Count" << std::endl;
252 os << "-----------------------------+---------+-------------" << std::endl;
253
254 bool found( false );
255
256 for ( auto itr = m_sourceMap.begin(); itr != m_sourceMap.end(); ++itr ) {
257 for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
258 if ( ( itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
259 ( m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value() ) ) {
260 os << " ";
261 os.width( 28 );
262 os.setf( std::ios_base::left, std::ios_base::adjustfield );
263 os << itr->first;
264 os << "|";
265
266 os.width( 8 );
267 os.setf( std::ios_base::right, std::ios_base::adjustfield );
268 os << levelNames[ic];
269 os << " |";
270
271 os.width( 9 );
272 os << itr->second.msg[ic];
273 os << std::endl;
274
275 found = true;
276 }
277 }
278 }
279 os << "=====================================================" << std::endl;
280 if ( found || m_stats ) std::cout << os.str();
281 }
282
283 #ifndef NDEBUG
284 if ( m_inactCount.value() ) {
285
286 std::ostringstream os;
287 os << "Listing sources of Unprotected and Unseen messages\n";
288
289 bool found( false );
290
291 unsigned int ml( 0 );
292 for ( const auto& itr : m_inactiveMap ) {
293 for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
294 if ( itr.second.msg[ic] != 0 && itr.first.length() > ml ) { ml = itr.first.length(); }
295 }
296 }
297
298 for ( unsigned int i = 0; i < ml + 25; ++i ) os << "=";
299
300 os << std::endl << " ";
301 os.width( ml + 2 );
302 os.setf( std::ios_base::left, std::ios_base::adjustfield );
303 os << "Message Source";
304 os.width( 1 );
305 os << "| Level | Count" << std::endl;
306
307 for ( unsigned int i = 0; i < ml + 3; ++i ) os << "-";
308 os << "+---------+-----------" << std::endl;
309
310 for ( auto itr = m_inactiveMap.begin(); itr != m_inactiveMap.end(); ++itr ) {
311 for ( unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
312 if ( itr->second.msg[ic] != 0 ) {
313 os << " ";
314 os.width( ml + 2 );
315 os.setf( std::ios_base::left, std::ios_base::adjustfield );
316 os << itr->first;
317
318 os << "|";
319
320 os.width( 8 );
321 os.setf( std::ios_base::right, std::ios_base::adjustfield );
322 os << levelNames[ic];
323
324 os << " |";
325
326 os.width( 9 );
327 os << itr->second.msg[ic];
328
329 os << std::endl;
330
331 found = true;
332 }
333 }
334 }
335 for ( unsigned int i = 0; i < ml + 25; ++i ) os << "=";
336 os << std::endl;
337
338 if ( found ) std::cout << os.str();
339 }
340 #endif
341
342 return StatusCode::SUCCESS;
343 }
std::ostringstream::setf
T setf(T... args)
MessageSvc::m_sourceMap
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:192
MessageSvc::m_inactiveMap
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:192
std::endl
T endl(T... args)
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MessageSvc::m_inactCount
Gaudi::Property< bool > m_inactCount
Definition: MessageSvc.h:165
MessageSvc::m_statLevel
Gaudi::Property< unsigned int > m_statLevel
Definition: MessageSvc.h:133
std::ostringstream
STL class.
std::ostringstream::width
T width(T... args)
std::ostringstream::str
T str(T... args)
MSG::NUM_LEVELS
Definition: IMessageSvc.h:15
MessageSvc::m_stats
Gaudi::Property< bool > m_stats
Definition: MessageSvc.h:132
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:155
MessageSvc::m_suppress
Gaudi::Property< bool > m_suppress
Definition: MessageSvc.h:164
std::cout

## ◆ getLogColor()

std::string MessageSvc::getLogColor | ( | int | logLevel | ) | const
| override

Definition at line 600 of file MessageSvc.cpp.

600 {
601 // ---------------------------------------------------------------------------
602 return ( logLevel < MSG::NUM_LEVELS ) ? m_logColorCodes[logLevel] : "";
603 }
MSG::NUM_LEVELS
Definition: IMessageSvc.h:15
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:182

## ◆ i_reportMessage() [1/2]

void MessageSvc::i_reportMessage | ( | const Message & | msg,
|  | int | outputLevel
| ) |  |
| protected virtual

Internal implementation of reportMessage(const Message&,int) without lock.

Definition at line 356 of file MessageSvc.cpp.

356 {
357 int key = msg.getType();
358
359 ++m_msgCount[key];
360
361 const Message* cmsg = &msg;
362
363 // processing logged streams
364 if ( !m_loggedStreams.empty() ) {
365 auto iLog = m_loggedStreams.find( msg.getSource() );
366 if ( m_loggedStreams.end() != iLog ) { ( *iLog->second ) << *cmsg << std::endl; }
367 }
368
369 if ( m_suppress.value() || m_stats.value() ) {
370
371 // Increase the counter of 'key' type of messages for the source and
372 // get the new value.
373 const int nmsg = ++( m_sourceMap[msg.getSource()].msg[key] );
374
375 if ( m_suppress.value() && m_msgLimit[key] != 0 ) {
376 if ( nmsg > m_msgLimit[key] ) return;
377 if ( nmsg == m_msgLimit[key] ) {
378 std::string txt = levelNames[key] + " message limit (" + std::to_string( m_msgLimit[key].value() ) +
379 ") reached for " + msg.getSource() + ". Suppressing further output.";
380 cmsg = new Message( msg.getSource(), MSG::WARNING, std::move( txt ) );
381 cmsg->setFormat( msg.getFormat() );
382 }
383 }
384 }
385
386 auto range = m_streamMap.equal_range( key );
387 if ( range.first != m_streamMap.end() ) {
388 std::for_each( range.first, range.second,
389 [&]( StreamMap::const_reference sm ) { *sm.second.second << *cmsg << std::endl; } );
390 } else if ( key >= outputLevel ) {
391 msg.setFormat( m_defaultFormat );
392 msg.setTimeFormat( m_defaultTimeFormat );
393 if ( !m_color ) {
394 ( *m_defaultStream ) << *cmsg << std::endl << std::flush;
395 } else {
396 ( *m_defaultStream ) << m_logColorCodes[key] << *cmsg << "\033[m" << std::endl << std::flush;
397 }
398 }
399
400 if ( cmsg != &msg ) { delete cmsg; }
401 }
std::map::empty
T empty(T... args)
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:71
MessageSvc::m_sourceMap
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:192
std::to_string
T to_string(T... args)
std::endl
T endl(T... args)
MessageSvc::m_defaultTimeFormat
Gaudi::Property< std::string > m_defaultTimeFormat
Definition: MessageSvc.h:131
std::map::end
T end(T... args)
Message::setFormat
void setFormat(std::string msg) const
Set the format string.
Definition: Message.cpp:143
std::string
STL class.
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:196
MessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:144
MessageSvc::m_defaultFormat
Gaudi::Property< std::string > m_defaultFormat
Definition: MessageSvc.h:130
std::move
T move(T... args)
std::flush
T flush(T... args)
std::map::find
T find(T... args)
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
Message
The Message class.
Definition: Message.h:17
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:182
MessageSvc::m_stats
Gaudi::Property< bool > m_stats
Definition: MessageSvc.h:132
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:194
MSG::WARNING
Definition: IMessageSvc.h:15
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:155
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:566
std::for_each
T for_each(T... args)
MessageSvc::m_suppress
Gaudi::Property< bool > m_suppress
Definition: MessageSvc.h:164
std::multimap::equal_range
T equal_range(T... args)

## ◆ i_reportMessage() [2/2]

void MessageSvc::i_reportMessage | ( | const StatusCode & | code,
|  | const std::string & | source
| ) |  |
| protected virtual

Internal implementation of reportMessage(const StatusCode&,const std::string&) without lock.

Definition at line 442 of file MessageSvc.cpp.

442 {
443 int level = outputLevel( source );
444 auto report = [&]( Message mesg ) {
445 mesg.setSource( source );
446 Message stat_code( source, mesg.getType(), "Status Code " + std::to_string( code.getCode() ) );
447 i_reportMessage( std::move( stat_code ), level );
448 i_reportMessage( std::move( mesg ), level );
449 };
450
451 auto range = m_messageMap.equal_range( code );
452 if ( range.first != m_messageMap.end() ) {
453 std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
454 } else {
455 report( m_defaultMessage );
456 }
457 }
StatusCode::getCode
code_t getCode() const
Retrieve value ("checks" the StatusCode)
Definition: StatusCode.h:137
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:71
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:356
MessageSvc::m_defaultMessage
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:177
std::to_string
T to_string(T... args)
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:179
std::multimap::end
T end(T... args)
std::move
T move(T... args)
Message
The Message class.
Definition: Message.h:17
gaudirun.level
level
Definition: gaudirun.py:334
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:566
std::for_each
T for_each(T... args)
std::multimap::equal_range
T equal_range(T... args)

## ◆ incrInactiveCount()

void MessageSvc::incrInactiveCount | ( | MSG::Level | level,
|  | const std::string & | src
| ) |  |
| override

Definition at line 609 of file MessageSvc.cpp.

609 {
610 ++( m_inactiveMap[source].msg[level] );
611
612 if ( std::find( begin( m_tracedInactiveSources ), end( m_tracedInactiveSources ), source ) !=
613 end( m_tracedInactiveSources ) ) {
614 std::cout << "== inactive message detected from " << source << " ==" << std::endl;
615 std::string t;
616 System::backTrace( t, 25, 0 );
617 std::cout << t << std::endl;
618 }
619 }
MessageSvc::m_inactiveMap
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:192
std::endl
T endl(T... args)
MessageSvc::m_tracedInactiveSources
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
Definition: MessageSvc.h:167
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
std::string
STL class.
IOTest.end
def end
Definition: IOTest.py:112
std::find
T find(T... args)
gaudirun.level
level
Definition: gaudirun.py:334
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
std::cout

## ◆ initialize()

StatusCode MessageSvc::initialize | ( |  | ) |
| override

Initialize Service.

Definition at line 106 of file MessageSvc.cpp.

106 {
107 StatusCode sc = Service::initialize();
108 if ( sc.isFailure() ) return sc;
109
110 #ifdef _WIN32
111 m_color = false;
112 #endif
113
114 // make sure the map of logged stream names is initialized
115 setupLogStreams();
116
117 return StatusCode::SUCCESS;
118 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:60
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MessageSvc::setupLogStreams
void setupLogStreams()
Definition: MessageSvc.cpp:622
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
MessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:144
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130

## ◆ insertMessage()

void MessageSvc::insertMessage | ( | const StatusCode & | code,
|  | const Message & | message
| ) |  |
| override

Definition at line 522 of file MessageSvc.cpp.

522 {
523 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
524 m_messageMap.emplace( key, msg );
525 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:179
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:212
std::lock
T lock(T... args)
std::unique_lock
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
std::multimap::emplace
T emplace(T... args)

## ◆ insertStream()

void MessageSvc::insertStream | ( | int | message_type,
|  | const std::string & | name,
|  | std::ostream * | stream
| ) |  |
| override

Definition at line 466 of file MessageSvc.cpp.

466 {
467 m_streamMap.emplace( key, NamedStream( name, stream ) );
468 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:178
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MessageSvc::NamedStream
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:32
std::multimap::emplace
T emplace(T... args)

## ◆ messageCount()

int MessageSvc::messageCount | ( | MSG::Level | logLevel | ) | const
| override

Definition at line 606 of file MessageSvc.cpp.

606 { return m_msgCount[level]; }
gaudirun.level
level
Definition: gaudirun.py:334
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:194

## ◆ outputLevel() [1/2]

int MessageSvc::outputLevel | ( |  | ) | const
| override

Definition at line 566 of file MessageSvc.cpp.

566 {
567 // ---------------------------------------------------------------------------
568 return m_outputLevel;
569 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176

## ◆ outputLevel() [2/2]

int MessageSvc::outputLevel | ( | const std::string & | source | ) | const
| override

Definition at line 572 of file MessageSvc.cpp.

572 {
573 // ---------------------------------------------------------------------------
574 std::unique_lock<std::recursive_mutex> lock( m_thresholdMapMutex );
575 auto it = m_thresholdMap.find( source );
576 return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
577 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176
std::map::end
T end(T... args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:180
std::lock
T lock(T... args)
std::map::find
T find(T... args)
std::unique_lock
MessageSvc::m_thresholdMapMutex
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:216

## ◆ reinitialize()

StatusCode MessageSvc::reinitialize | ( |  | ) |
| override

Reinitialize Service.

Definition at line 123 of file MessageSvc.cpp.

123 {
124 m_state = Gaudi::StateMachine::OFFLINE;
125 StatusCode sc = initialize();
126 if ( sc.isSuccess() ) m_state = Gaudi::StateMachine::INITIALIZED;
127
128 return sc;
129 }
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
MessageSvc::initialize
StatusCode initialize() override
Initialize Service.
Definition: MessageSvc.cpp:106
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
Gaudi::StateMachine::OFFLINE
Definition: StateMachine.h:13

## ◆ reportMessage() [1/5]

void MessageSvc::reportMessage | ( | const Message & | message | ) |
| override

Definition at line 409 of file MessageSvc.cpp.

409 { reportMessage( msg, outputLevel( msg.getSource() ) ); }
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:409
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:566

## ◆ reportMessage() [2/5]

void MessageSvc::reportMessage | ( | const Message & | msg,
|  | int | outputLevel
| ) |  |
| override

Definition at line 351 of file MessageSvc.cpp.

351 {
352 std::unique_lock<std::recursive_mutex> lock( m_reportMutex );
353 i_reportMessage( msg, outputLevel );
354 }
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:356
std::lock
T lock(T... args)
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:209
std::unique_lock
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:566

## ◆ reportMessage() [3/5]

void MessageSvc::reportMessage | ( | const StatusCode & | code,
|  | const std::string & | source = `""`
| ) |  |
| override

Definition at line 437 of file MessageSvc.cpp.

437 {
438 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
439 i_reportMessage( code, source );
440 }
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:356
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:212
std::lock
T lock(T... args)
std::unique_lock

## ◆ reportMessage() [4/5]

void MessageSvc::reportMessage | ( | const char * | source,
|  | int | type,
|  | const char * | message
| ) |  |
| override

Definition at line 417 of file MessageSvc.cpp.

417 {
418 reportMessage( Message{source, type, message} );
419 }
gaudirun.type
type
Definition: gaudirun.py:142
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:409
Message
The Message class.
Definition: Message.h:17

## ◆ reportMessage() [5/5]

void MessageSvc::reportMessage | ( | const std::string & | source,
|  | int | type,
|  | const std::string & | message
| ) |  |
| override

Definition at line 427 of file MessageSvc.cpp.

427 {
428 reportMessage( Message{source, type, message} );
429 }
gaudirun.type
type
Definition: gaudirun.py:142
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:409
Message
The Message class.
Definition: Message.h:17

## ◆ setDefaultStream()

void MessageSvc::setDefaultStream | ( | std::ostream * | stream | ) |
| inline override

Definition at line 93 of file MessageSvc.h.

93 {
94 std::unique_lock<std::recursive_mutex> lock( m_reportMutex );
95 m_defaultStream = stream;
96 }
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:176
std::lock
T lock(T... args)
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:209
std::unique_lock

## ◆ setOutputLevel() [1/2]

void MessageSvc::setOutputLevel | ( | int | new_level | ) |
| override

Definition at line 580 of file MessageSvc.cpp.

580 {
581 // ---------------------------------------------------------------------------
582 m_outputLevel = new_level;
583 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:176

## ◆ setOutputLevel() [2/2]

void MessageSvc::setOutputLevel | ( | const std::string & | source,
|  | int | new_level
| ) |  |
| override

Definition at line 586 of file MessageSvc.cpp.

586 {
587 // ---------------------------------------------------------------------------
588 std::unique_lock<std::recursive_mutex> lock( m_thresholdMapMutex );
589
590 // only write if we really have to...
591 auto i = m_thresholdMap.find( source );
592 if ( i == m_thresholdMap.end() ) {
593 m_thresholdMap[source] = level;
594 } else if ( i->second != level ) {
595 i->second = level;
596 }
597 }
std::map::end
T end(T... args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:180
std::lock
T lock(T... args)
std::map::find
T find(T... args)
std::unique_lock
gaudirun.level
level
Definition: gaudirun.py:334
MessageSvc::m_thresholdMapMutex
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:216

## ◆ setupColors()

void MessageSvc::setupColors | ( | Gaudi::Details::PropertyBase & | prop | ) |
| private

Definition at line 133 of file MessageSvc.cpp.

133 {
134 const std::string& pname = prop.name();
135 int level;
136 if ( pname == "fatalColorCode" )
137 level = MSG::FATAL;
138 else if ( pname == "errorColorCode" )
139 level = MSG::ERROR;
140 else if ( pname == "warningColorCode" )
141 level = MSG::WARNING;
142 else if ( pname == "infoColorCode" )
143 level = MSG::INFO;
144 else if ( pname == "debugColorCode" )
145 level = MSG::DEBUG;
146 else if ( pname == "verboseColorCode" )
147 level = MSG::VERBOSE;
148 else if ( pname == "alwaysColorCode" )
149 level = MSG::ALWAYS;
150 else {
151 throw GaudiException( "ERROR: Unknown message color parameter: " + pname, name(), StatusCode::FAILURE );
152 }
153
154 auto& code = m_logColorCodes[level];
155
156 const auto& col_desc = m_logColors[level].value();
157
158 if ( col_desc.size() == 1 ) {
159 const std::string& desc = col_desc[0];
160 if ( desc.empty() ) {
161 code = "";
162 } else if ( desc[0] == '[' ) {
163 code = "\033" + desc;
164 } else {
165 code = "\033[" + colTrans( desc, 90 ) + ";1m";
166 }
167 } else if ( col_desc.size() == 2 ) {
168 code = "\033[" + colTrans( col_desc[0], 90 ) + ";" + colTrans( col_desc[1], 100 ) + ";1m";
169 } else { // empty desc: no color
170 code = "";
171 }
172 }
std::string::empty
T empty(T... args)
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
MSG::DEBUG
Definition: IMessageSvc.h:15
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
MSG::VERBOSE
Definition: IMessageSvc.h:15
std::string
STL class.
MSG::FATAL
Definition: IMessageSvc.h:15
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
MessageSvc::m_logColors
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Definition: MessageSvc.h:146
compareOutputFiles.pname
string pname
Definition: compareOutputFiles.py:470
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:182
gaudirun.level
level
Definition: gaudirun.py:334
MSG::WARNING
Definition: IMessageSvc.h:15
MSG::INFO
Definition: IMessageSvc.h:15
MSG::ALWAYS
Definition: IMessageSvc.h:15

## ◆ setupInactCount()

void MessageSvc::setupInactCount | ( | Gaudi::Details::PropertyBase & | prop | ) |
| private

Definition at line 227 of file MessageSvc.cpp.

227 {
228 if ( prop.name() == "countInactive" ) {
229 Gaudi::Property<bool>* p = dynamic_cast<Gaudi::Property<bool>*>( &prop );
230 if ( p ) MsgStream::enableCountInactive( p->value() );
231 }
232 }
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:526
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:31

## ◆ setupLimits()

void MessageSvc::setupLimits | ( | Gaudi::Details::PropertyBase & | prop | ) |
| private

Definition at line 175 of file MessageSvc.cpp.

175 {
176 // Just report problems in the settings of the limits and unknown limit parameters
177 if ( prop.name() == "alwaysLimit" ) {
178 Gaudi::Property<int>* p = dynamic_cast<Gaudi::Property<int>*>( &prop );
179 if ( p && p->value() != 0 ) {
180 std::cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
181 p->setValue( 0 );
182 }
183 } else if ( prop.name() == "defaultLimit" ) {
184 for ( int i = MSG::VERBOSE; i < MSG::NUM_LEVELS; ++i ) {
185 if ( i != MSG::ALWAYS ) { m_msgLimit[i] = m_msgLimit[MSG::NIL].value(); }
186 }
187 } else if ( prop.name() != "fatalLimit" && prop.name() != "errorLimit" && prop.name() != "warningLimit" &&
188 prop.name() == "infoLimit" && prop.name() == "debugLimit" && prop.name() == "verboseLimit" ) {
189 std::cout << "MessageSvc ERROR: Unknown message limit parameter: " << prop.name() << std::endl;
190 return;
191 }
192 }
Gaudi::Property::setValue
bool setValue(const ValueType &v)
Definition: Property.h:528
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
std::endl
T endl(T... args)
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
MSG::VERBOSE
Definition: IMessageSvc.h:15
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:526
MSG::NIL
Definition: IMessageSvc.h:15
MSG::NUM_LEVELS
Definition: IMessageSvc.h:15
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:155
std::cout
MSG::ALWAYS
Definition: IMessageSvc.h:15

## ◆ setupLogStreams()

void MessageSvc::setupLogStreams | ( |  | ) |
| private

Definition at line 622 of file MessageSvc.cpp.

622 {
623 // reset state
624 m_loggedStreams.clear();
625
626 for ( auto& iProp : m_loggedStreamsName ) {
627
628 std::set<std::string> outFileNames;
629 for ( auto& jProp : m_loggedStreamsName ) {
630 if ( jProp.first != iProp.first ) { outFileNames.insert( jProp.second ); }
631 }
632 tee( iProp.first, iProp.second, outFileNames );
633
634 } //> loop over property entries
635 }
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:196
std::map::clear
T clear(T... args)
std::set::insert
T insert(T... args)
std::set< std::string >
MessageSvc::tee
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
Definition: MessageSvc.cpp:638
MessageSvc::m_loggedStreamsName
Gaudi::Property< std::map< std::string, std::string > > m_loggedStreamsName
Definition: MessageSvc.h:173

## ◆ setupThreshold()

void MessageSvc::setupThreshold | ( | Gaudi::Details::PropertyBase & | prop | ) |
| private

Definition at line 195 of file MessageSvc.cpp.

195 {
196
197 static const std::array<std::pair<const char*, MSG::Level>, 7> tbl{{{"setFatal", MSG::FATAL},
198 {"setError", MSG::ERROR},
199 {"setWarning", MSG::WARNING},
200 {"setInfo", MSG::INFO},
201 {"setDebug", MSG::DEBUG},
202 {"setVerbose", MSG::VERBOSE},
203 {"setAlways", MSG::ALWAYS}}};
204
205 auto i = std::find_if( std::begin( tbl ), std::end( tbl ),
206 [&]( const std::pair<const char*, MSG::Level>& t ) { return prop.name() == t.first; } );
207 if ( i == std::end( tbl ) ) {
208 std::cerr << "MessageSvc ERROR: Unknown message threshold parameter: " << prop.name() << std::endl;
209 return;
210 }
211 int ic = i->second;
212
213 Gaudi::Property<std::vector<std::string>>* sap = dynamic_cast<Gaudi::Property<std::vector<std::string>>*>( &prop );
214 if ( !sap ) {
215 std::cerr << "could not dcast " << prop.name()
216 << " to a Gaudi::Property<std::vector<std::string>> (which it should be!)" << std::endl;
217 } else {
218 for ( auto& i : sap->value() ) setOutputLevel( i, ic );
219 }
220 }
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
MSG::DEBUG
Definition: IMessageSvc.h:15
std::endl
T endl(T... args)
std::end
T end(T... args)
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
MSG::VERBOSE
Definition: IMessageSvc.h:15
MSG::FATAL
Definition: IMessageSvc.h:15
MessageSvc::setOutputLevel
void setOutputLevel(int new_level) override
Definition: MessageSvc.cpp:580
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:526
std::pair
std::find_if
T find_if(T... args)
std::begin
T begin(T... args)
std::array
STL class.
MSG::ERROR
Definition: IMessageSvc.h:15
MSG::WARNING
Definition: IMessageSvc.h:15
MSG::INFO
Definition: IMessageSvc.h:15
std::cerr
MSG::ALWAYS
Definition: IMessageSvc.h:15

## ◆ tee()

void MessageSvc::tee | ( | const std::string & | sourceName,
|  | const std::string & | logFileName,
|  | const std::set< std::string > & | declaredOutFileNames
| ) |  |
| private

Definition at line 638 of file MessageSvc.cpp.

639 {
640 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
641
642 auto iStream = m_loggedStreams.find( sourceName );
643 if ( iStream != std::end( m_loggedStreams ) ) { m_loggedStreams.erase( iStream ); }
644
645 // before creating a new ofstream, make sure there is no already existing
646 // one with the same file name...
647 for ( auto& iStream : m_loggedStreams ) {
648 if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
649 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
650 return;
651 }
652 }
653
654 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
655 if ( out->good() ) m_loggedStreams[sourceName] = std::move( out );
656 }
std::end
T end(T... args)
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:196
std::map::erase
T erase(T... args)
std::move
T move(T... args)
std::map::find
T find(T... args)

## ◆ useColor()

bool MessageSvc::useColor | ( |  | ) | const
| inline override

Definition at line 111 of file MessageSvc.h.

111 { return m_color; }
MessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:144

## Member Data Documentation

## ◆ m_color

Gaudi::Property<bool> MessageSvc::m_color {this, "useColors", false, ""}
| private

Definition at line 144 of file MessageSvc.h.

## ◆ m_defaultFormat

Gaudi::Property<std::string> MessageSvc::m_defaultFormat {this, "Format", Message::getDefaultFormat(), ""}
| private

Definition at line 130 of file MessageSvc.h.

## ◆ m_defaultMessage

Message MessageSvc::m_defaultMessage
| private

Default Message.

Definition at line 177 of file MessageSvc.h.

## ◆ m_defaultStream

std::ostream* MessageSvc::m_defaultStream = &std::cout
| private

Pointer to the output stream.

Definition at line 176 of file MessageSvc.h.

## ◆ m_defaultTimeFormat

Gaudi::Property<std::string> MessageSvc::m_defaultTimeFormat {this, "timeFormat", Message::getDefaultTimeFormat(), ""}
| private

Definition at line 131 of file MessageSvc.h.

## ◆ m_inactCount

Gaudi::Property<bool> MessageSvc::m_inactCount {this, "countInactive", false, &MessageSvc::setupInactCount, ""}
| private

Definition at line 165 of file MessageSvc.h.

## ◆ m_inactiveMap

std::map<std::string, MsgAry> MessageSvc::m_inactiveMap
| private

Definition at line 192 of file MessageSvc.h.

## ◆ m_logColorCodes

std::string MessageSvc::m_logColorCodes[MSG::NUM_LEVELS]
| private

Definition at line 182 of file MessageSvc.h.

## ◆ m_logColors

std::array<Gaudi::Property<std::vector<std::string> >, MSG::NUM_LEVELS> MessageSvc::m_logColors
| private

Initial value:
{{{},
{this, "verboseColorCode"},
{this, "debugColorCode"},
{this, "infoColorCode"},
{this, "warningColorCode"},
{this, "errorColorCode"},
{this, "fatalColorCode"},
{this, "alwaysColorCode"}}}

Definition at line 146 of file MessageSvc.h.

## ◆ m_loggedStreams

std::map<std::string, std::shared_ptr<std::ostream> > MessageSvc::m_loggedStreams
| private

Definition at line 196 of file MessageSvc.h.

## ◆ m_loggedStreamsName

Gaudi::Property<std::map<std::string, std::string> > MessageSvc::m_loggedStreamsName
| private

Initial value:
{
this, "loggedStreams", {}, "MessageStream sources we want to dump into a logfile"}

Definition at line 173 of file MessageSvc.h.

## ◆ m_messageMap

MessageMap MessageSvc::m_messageMap
| private

Message map.

Definition at line 179 of file MessageSvc.h.

## ◆ m_messageMapMutex

std::recursive_mutex MessageSvc::m_messageMapMutex
| mutable private

Mutex to synchronize multiple access to m_messageMap.

Definition at line 212 of file MessageSvc.h.

## ◆ m_msgCount

std::array<int, MSG::NUM_LEVELS> MessageSvc::m_msgCount
| private

Definition at line 194 of file MessageSvc.h.

## ◆ m_msgLimit

std::array<Gaudi::Property<int>, MSG::NUM_LEVELS> MessageSvc::m_msgLimit
| private

Initial value:
{{{this, "defaultLimit", 500},
{this, "verboseLimit", 500},
{this, "debugLimit", 500},
{this, "infoLimit", 500},
{this, "warningLimit", 500},
{this, "errorLimit", 500},
{this, "fatalLimit", 500},
{this, "alwaysLimit", 0}}}

Definition at line 155 of file MessageSvc.h.

## ◆ m_reportMutex

std::recursive_mutex MessageSvc::m_reportMutex
| mutable private

Mutex to synchronize multiple threads printing.

Definition at line 209 of file MessageSvc.h.

## ◆ m_sourceMap

std::map<std::string, MsgAry> MessageSvc::m_sourceMap
| private

Definition at line 192 of file MessageSvc.h.

## ◆ m_statLevel

Gaudi::Property<unsigned int> MessageSvc::m_statLevel {this, "statLevel", 0, ""}
| private

Definition at line 133 of file MessageSvc.h.

## ◆ m_stats

Gaudi::Property<bool> MessageSvc::m_stats {this, "showStats", false, ""}
| private

Definition at line 132 of file MessageSvc.h.

## ◆ m_streamMap

StreamMap MessageSvc::m_streamMap
| private

Stream map.

Definition at line 178 of file MessageSvc.h.

## ◆ m_suppress

Gaudi::Property<bool> MessageSvc::m_suppress {this, "enableSuppression", false, ""}
| private

Definition at line 164 of file MessageSvc.h.

## ◆ m_thresholdMap

ThresholdMap MessageSvc::m_thresholdMap
| private

Output level threshold map.

Definition at line 180 of file MessageSvc.h.

## ◆ m_thresholdMapMutex

std::recursive_mutex MessageSvc::m_thresholdMapMutex
| mutable private

Mutex to synchronize multiple access to m_thresholdMap (.

See also
  MsgStream::doOutput).

Definition at line 216 of file MessageSvc.h.

## ◆ m_thresholdProp

std::array<Gaudi::Property<std::vector<std::string> >, MSG::NUM_LEVELS> MessageSvc::m_thresholdProp
| private

Initial value:
{{{},
{this, "setVerbose"},
{this, "setDebug"},
{this, "setInfo"},
{this, "setWarning"},
{this, "setError"},
{this, "setFatal"},
{this, "setAlways"}}}

Definition at line 135 of file MessageSvc.h.

## ◆ m_tracedInactiveSources

Gaudi::Property<std::vector<std::string> > MessageSvc::m_tracedInactiveSources
| private

Initial value:
{
this,
"tracedInactiveSources",
{},
"for each message source specified, print a stack trace for the unprotected and unseen messages"}

Definition at line 167 of file MessageSvc.h.

The documentation for this class was generated from the following files:

- GaudiCoreSvc/src/MessageSvc/MessageSvc.h
- GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp