| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
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)
| ~MessageSvc () override=default
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...
| ~extends () override=default
| Virtual destructor. 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 | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public 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
| ~PropertyHolder () override=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, TYPE &value, const std::string &doc="none") const
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
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
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...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. 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 > >
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, ""}
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, "[[deprecated]] 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

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

Definition at line 35 of file MessageSvc.h.

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

Definition at line 33 of file MessageSvc.h.

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

Definition at line 34 of file MessageSvc.h.

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

Definition at line 36 of file MessageSvc.h.

## Constructor & Destructor Documentation

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

Definition at line 73 of file MessageSvc.cpp.

73 : base_class( name, svcloc )
74 {
75 m_inactCount.declareUpdateHandler( &MessageSvc::setupInactCount, this );
76
77 #ifndef NDEBUG
78 // initialize the MsgStream static flag.
79 MsgStream::enableCountInactive( m_inactCount );
80 #endif
81
82 for ( int ic = 0; ic < MSG::NUM_LEVELS; ++ic ) {
83 m_logColors[ic].declareUpdateHandler( &MessageSvc::setupColors, this );
84 m_msgLimit[ic].declareUpdateHandler( &MessageSvc::setupLimits, this );
85 m_thresholdProp[ic].declareUpdateHandler( &MessageSvc::setupThreshold, this );
86 }
87
88 m_logColors[MSG::FATAL].set({"blue", "red"});
89 m_logColors[MSG::ERROR].set({"white", "red"});
90 m_logColors[MSG::WARNING].set({"yellow"});
91
92 std::fill( std::begin( m_msgCount ), std::end( m_msgCount ), 0 );
93 }
MessageSvc::setupInactCount
void setupInactCount(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:216
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:124
MSG::FATAL
Definition: IMessageSvc.h:22
MessageSvc::m_inactCount
Gaudi::Property< bool > m_inactCount
Definition: MessageSvc.h:169
MessageSvc::m_logColors
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Definition: MessageSvc.h:150
std::begin
T begin(T...args)
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MSG::ERROR
Definition: IMessageSvc.h:21
MessageSvc::setupLimits
void setupLimits(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:160
MessageSvc::setupThreshold
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Definition: MessageSvc.cpp:183
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:198
MessageSvc::m_thresholdProp
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
Definition: MessageSvc.h:139
MSG::WARNING
Definition: IMessageSvc.h:20
std::fill
T fill(T...args)
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:159
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32

MessageSvc::~MessageSvc | ( |  | ) |
| override default

## Member Function Documentation

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

Definition at line 93 of file MessageSvc.h.

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

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

Definition at line 541 of file MessageSvc.cpp.

542 {
543 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
544 m_messageMap.clear();
545 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:183
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:216
std::lock
T lock(T...args)
std::multimap::clear
T clear(T...args)
std::unique_lock

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

Definition at line 554 of file MessageSvc.cpp.

555 {
556 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
557 m_messageMap.erase( key );
558 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:183
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:216
std::multimap::erase
T erase(T...args)
std::lock
T lock(T...args)
std::unique_lock

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

Definition at line 567 of file MessageSvc.cpp.

568 {
569 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
570
571 erase_if( m_messageMap, m_messageMap.equal_range( key ),
572 [&]( MessageMap::const_reference j ) { return j.second == msg; } );
573 }
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:132
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:183
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:216
std::lock
T lock(T...args)
std::unique_lock
std::multimap::equal_range
T equal_range(T...args)

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

Definition at line 481 of file MessageSvc.cpp.

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

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

Definition at line 490 of file MessageSvc.cpp.

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

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

Definition at line 499 of file MessageSvc.cpp.

500 {
501 if ( stream ) {
502 erase_if( m_streamMap, m_streamMap.equal_range( key ),
503 [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
504 }
505 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:182
std::multimap::equal_range
T equal_range(T...args)

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

Definition at line 514 of file MessageSvc.cpp.

515 {
516 if ( stream ) {
517 erase_if( m_streamMap, [&]( StreamMap::const_reference j ) { return j.second.second == stream; } );
518 }
519 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:182

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

Finalize Service.

Definition at line 227 of file MessageSvc.cpp.

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

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

Definition at line 614 of file MessageSvc.cpp.

615 {
616 // ---------------------------------------------------------------------------
617 return ( logLevel < MSG::NUM_LEVELS ) ? m_logColorCodes[logLevel] : "";
618 }
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:186

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

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

Definition at line 350 of file MessageSvc.cpp.

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

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 444 of file MessageSvc.cpp.

445 {
446 int level = outputLevel( source );
447 auto report = [&]( Message mesg ) {
448 mesg.setSource( source );
449 Message stat_code( source, mesg.getType(), "Status Code " + std::to_string( code.getCode() ) );
450 i_reportMessage( std::move( stat_code ), level );
451 i_reportMessage( std::move( mesg ), level );
452 };
453
454 auto range = m_messageMap.equal_range( code );
455 if ( range.first != m_messageMap.end() ) {
456 std::for_each( range.first, range.second, [&]( MessageMap::const_reference sm ) { report( sm.second ); } );
457 } else {
458 report( m_defaultMessage );
459 }
460 }
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:91
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:57
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:350
MessageSvc::m_defaultMessage
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:181
std::to_string
T to_string(T...args)
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:183
std::multimap::end
T end(T...args)
std::move
T move(T...args)
Message
The Message class.
Definition: Message.h:15
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:576
gaudirun.level
level
Definition: gaudirun.py:261
std::for_each
T for_each(T...args)
std::multimap::equal_range
T equal_range(T...args)

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

Definition at line 624 of file MessageSvc.cpp.

625 {
626 ++( m_inactiveMap[source].msg[level] );
627
628 if ( std::find( begin( m_tracedInactiveSources ), end( m_tracedInactiveSources ), source ) !=
629 end( m_tracedInactiveSources ) ) {
630 std::cout << "== inactive message detected from " << source << " ==" << std::endl;
631 std::string t;
632 System::backTrace( t, 25, 0 );
633 std::cout << t << std::endl;
634 }
635 }
MessageSvc::m_inactiveMap
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:196
std::endl
T endl(T...args)
MessageSvc::m_tracedInactiveSources
Gaudi::Property< std::vector< std::string > > m_tracedInactiveSources
Definition: MessageSvc.h:171
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
std::string
STL class.
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:50
std::find
T find(T...args)
gaudirun.level
level
Definition: gaudirun.py:261
std::cout

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

Initialize Service.

Definition at line 98 of file MessageSvc.cpp.

99 {
100 StatusCode sc = Service::initialize();
101 if ( sc.isFailure() ) return sc;
102
103 #ifdef _WIN32
104 m_color = false;
105 #endif
106
107 // make sure the map of logged stream names is initialized
108 setupLogStreams();
109
110 return StatusCode::SUCCESS;
111 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:30
MessageSvc::setupLogStreams
void setupLogStreams()
Definition: MessageSvc.cpp:638
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
MessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:148

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

Definition at line 528 of file MessageSvc.cpp.

529 {
530 std::unique_lock<std::recursive_mutex> lock( m_messageMapMutex );
531 m_messageMap.emplace( key, msg );
532 }
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:132
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:183
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:216
std::lock
T lock(T...args)
std::unique_lock
std::multimap::emplace
T emplace(T...args)

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

Definition at line 469 of file MessageSvc.cpp.

470 {
471 m_streamMap.emplace( key, NamedStream( name, stream ) );
472 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:182
MessageSvc::NamedStream
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:33
std::multimap::emplace
T emplace(T...args)

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

Definition at line 621 of file MessageSvc.cpp.

621 { return m_msgCount[level]; }
gaudirun.level
level
Definition: gaudirun.py:261
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:198

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

Definition at line 576 of file MessageSvc.cpp.

577 {
578 // ---------------------------------------------------------------------------
579 return m_outputLevel;
580 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:214

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

Definition at line 583 of file MessageSvc.cpp.

584 {
585 // ---------------------------------------------------------------------------
586 std::unique_lock<std::recursive_mutex> lock( m_thresholdMapMutex );
587 auto it = m_thresholdMap.find( source );
588 return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
589 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:214
std::map::end
T end(T...args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:184
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:220

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

Reinitialize Service.

Definition at line 116 of file MessageSvc.cpp.

117 {
118 m_state = Gaudi::StateMachine::OFFLINE;
119 return initialize();
120 }
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:191
MessageSvc::initialize
StatusCode initialize() override
Initialize Service.
Definition: MessageSvc.cpp:98
Gaudi::StateMachine::OFFLINE
Definition: StateMachine.h:13

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

Definition at line 408 of file MessageSvc.cpp.

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

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

Definition at line 344 of file MessageSvc.cpp.

345 {
346 std::unique_lock<std::recursive_mutex> lock( m_reportMutex );
347 i_reportMessage( msg, outputLevel );
348 }
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:350
std::lock
T lock(T...args)
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:213
std::unique_lock
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:576

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

Definition at line 438 of file MessageSvc.cpp.

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

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

Definition at line 416 of file MessageSvc.cpp.

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

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

Definition at line 427 of file MessageSvc.cpp.

428 {
429 reportMessage( Message{source, type, message} );
430 }
gaudirun.type
type
Definition: gaudirun.py:125
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:408
Message
The Message class.
Definition: Message.h:15

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

Definition at line 96 of file MessageSvc.h.

97 {
98 std::unique_lock<std::recursive_mutex> lock( m_reportMutex );
99 m_defaultStream = stream;
100 }
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:180
std::lock
T lock(T...args)
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:213
std::unique_lock

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

Definition at line 592 of file MessageSvc.cpp.

593 {
594 // ---------------------------------------------------------------------------
595 m_outputLevel = new_level;
596 }
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
Definition: Service.h:214

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

Definition at line 599 of file MessageSvc.cpp.

600 {
601 // ---------------------------------------------------------------------------
602 std::unique_lock<std::recursive_mutex> lock( m_thresholdMapMutex );
603
604 // only write if we really have to...
605 auto i = m_thresholdMap.find( source );
606 if ( i == m_thresholdMap.end() ) {
607 m_thresholdMap[source] = level;
608 } else if ( i->second != level ) {
609 i->second = level;
610 }
611 }
std::map::end
T end(T...args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:184
std::lock
T lock(T...args)
std::map::find
T find(T...args)
std::unique_lock
gaudirun.level
level
Definition: gaudirun.py:261
MessageSvc::m_thresholdMapMutex
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:220

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

Definition at line 124 of file MessageSvc.cpp.

125 {
126 const std::string& pname = prop.name();
127 int level;
128 if ( pname == "fatalColorCode" ) level = MSG::FATAL ; else
129 if ( pname == "errorColorCode" ) level = MSG::ERROR ; else
130 if ( pname == "warningColorCode" ) level = MSG::WARNING ; else
131 if ( pname == "infoColorCode" ) level = MSG::INFO ; else
132 if ( pname == "debugColorCode" ) level = MSG::DEBUG ; else
133 if ( pname == "verboseColorCode" ) level = MSG::VERBOSE ; else
134 if ( pname == "alwaysColorCode" ) level = MSG::ALWAYS ; else {
135 throw GaudiException( "ERROR: Unknown message color parameter: " + pname,
136 name(), StatusCode::FAILURE );
137 }
138
139 auto& code = m_logColorCodes[level];
140
141 const auto& col_desc = m_logColors[level].value();
142
143 if ( col_desc.size() == 1 ) {
144 const std::string& desc = col_desc[0];
145 if ( desc.empty() ) {
146 code = "";
147 } else if ( desc[0] == '[' ) {
148 code = "\033" + desc;
149 } else {
150 code = "\033[" + colTrans( desc, 90 ) + ";1m";
151 }
152 } else if ( col_desc.size() == 2 ) {
153 code = "\033[" + colTrans( col_desc[0], 90 ) + ";" + colTrans( col_desc[1], 100 ) + ";1m";
154 } else { // empty desc: no color
155 code = "";
156 }
157 }
std::string::empty
T empty(T...args)
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode::FAILURE
Definition: StatusCode.h:29
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
MSG::DEBUG
Definition: IMessageSvc.h:18
MSG::VERBOSE
Definition: IMessageSvc.h:17
std::string
STL class.
MSG::FATAL
Definition: IMessageSvc.h:22
MessageSvc::m_logColors
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_logColors
Definition: MessageSvc.h:150
compareOutputFiles.pname
pname
Definition: compareOutputFiles.py:392
MSG::ERROR
Definition: IMessageSvc.h:21
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:186
gaudirun.level
level
Definition: gaudirun.py:261
MSG::WARNING
Definition: IMessageSvc.h:20
MSG::INFO
Definition: IMessageSvc.h:19
MSG::ALWAYS
Definition: IMessageSvc.h:23

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

Definition at line 216 of file MessageSvc.cpp.

217 {
218 if ( prop.name() == "countInactive" ) {
219 Gaudi::Property<bool>* p = dynamic_cast<Gaudi::Property<bool>*>( &prop );
220 if ( p ) MsgStream::enableCountInactive( p->value() );
221 }
222 }
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:475
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32

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

Definition at line 160 of file MessageSvc.cpp.

161 {
162 // Just report problems in the settings of the limits and unknown limit parameters
163 if ( prop.name() == "alwaysLimit" ) {
164 Gaudi::Property<int>* p = dynamic_cast<Gaudi::Property<int>*>( &prop );
165 if ( p && p->value() != 0 ) {
166 std::cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
167 p->setValue( 0 );
168 }
169 } else if ( prop.name() == "defaultLimit" ) {
170 for ( int i = MSG::VERBOSE; i < MSG::NUM_LEVELS; ++i ) {
171 if ( i != MSG::ALWAYS ) {
172 m_msgLimit[i] = m_msgLimit[MSG::NIL].value();
173 }
174 }
175 } else if ( prop.name() != "fatalLimit" && prop.name() != "errorLimit" && prop.name() != "warningLimit" &&
176 prop.name() == "infoLimit" && prop.name() == "debugLimit" && prop.name() == "verboseLimit" ) {
177 std::cout << "MessageSvc ERROR: Unknown message limit parameter: " << prop.name() << std::endl;
178 return;
179 }
180 }
Gaudi::Property::setValue
bool setValue(const ValueType &v)
Definition: Property.h:477
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
std::endl
T endl(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:17
MSG::NIL
Definition: IMessageSvc.h:16
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:475
MessageSvc::m_msgLimit
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
Definition: MessageSvc.h:159
std::cout
MSG::ALWAYS
Definition: IMessageSvc.h:23

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

Definition at line 638 of file MessageSvc.cpp.

639 {
640 // reset state
641 m_loggedStreams.clear();
642
643 for ( auto& iProp : m_loggedStreamsName ) {
644
645 std::set<std::string> outFileNames;
646 for ( auto& jProp : m_loggedStreamsName ) {
647 if ( jProp.first != iProp.first ) {
648 outFileNames.insert( jProp.second );
649 }
650 }
651 tee( iProp.first, iProp.second, outFileNames );
652
653 } //> loop over property entries
654 }
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:200
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:657
MessageSvc::m_loggedStreamsName
Gaudi::Property< std::map< std::string, std::string > > m_loggedStreamsName
Definition: MessageSvc.h:177

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

Definition at line 183 of file MessageSvc.cpp.

184 {
185
186 static const std::array<std::pair<const char*, MSG::Level>, 7> tbl{{{"setFatal", MSG::FATAL},
187 {"setError", MSG::ERROR},
188 {"setWarning", MSG::WARNING},
189 {"setInfo", MSG::INFO},
190 {"setDebug", MSG::DEBUG},
191 {"setVerbose", MSG::VERBOSE},
192 {"setAlways", MSG::ALWAYS}}};
193
194 auto i = std::find_if( std::begin( tbl ), std::end( tbl ),
195 [&]( const std::pair<const char*, MSG::Level>& t ) { return prop.name() == t.first; } );
196 if ( i == std::end( tbl ) ) {
197 std::cerr << "MessageSvc ERROR: Unknown message threshold parameter: " << prop.name() << std::endl;
198 return;
199 }
200 int ic = i->second;
201
202 Gaudi::Property<std::vector<std::string>>* sap = dynamic_cast<Gaudi::Property<std::vector<std::string>>*>( &prop );
203 if ( !sap ) {
204 std::cerr << "could not dcast " << prop.name()
205 << " to a Gaudi::Property<std::vector<std::string>> (which it should be!)" << std::endl;
206 } else {
207 for ( auto& i : sap->value() ) setOutputLevel( i, ic );
208 }
209 }
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:40
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
std::end
T end(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:17
MSG::FATAL
Definition: IMessageSvc.h:22
MessageSvc::setOutputLevel
void setOutputLevel(int new_level) override
Definition: MessageSvc.cpp:592
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:21
MSG::WARNING
Definition: IMessageSvc.h:20
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:475
MSG::INFO
Definition: IMessageSvc.h:19
std::cerr
MSG::ALWAYS
Definition: IMessageSvc.h:23

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

Definition at line 657 of file MessageSvc.cpp.

659 {
660 const std::ios_base::openmode openMode = std::ios_base::out | std::ios_base::trunc;
661
662 auto iStream = m_loggedStreams.find( sourceName );
663 if ( iStream != std::end( m_loggedStreams ) ) {
664 m_loggedStreams.erase( iStream );
665 }
666
667 // before creating a new ofstream, make sure there is no already existing
668 // one with the same file name...
669 for ( auto& iStream : m_loggedStreams ) {
670 if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
671 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
672 return;
673 }
674 }
675
676 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
677 if ( out->good() ) m_loggedStreams[sourceName] = std::move( out );
678 }
std::end
T end(T...args)
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:200
std::map::erase
T erase(T...args)
std::move
T move(T...args)
std::map::find
T find(T...args)

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

Definition at line 115 of file MessageSvc.h.

115 { return m_color; }
MessageSvc::m_color
Gaudi::Property< bool > m_color
Definition: MessageSvc.h:148

## Member Data Documentation

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

Definition at line 148 of file MessageSvc.h.

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

Definition at line 134 of file MessageSvc.h.

Message MessageSvc::m_defaultMessage
| private

Default Message.

Definition at line 181 of file MessageSvc.h.

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

Pointer to the output stream.

Definition at line 180 of file MessageSvc.h.

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

Definition at line 135 of file MessageSvc.h.

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

Definition at line 169 of file MessageSvc.h.

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

Definition at line 196 of file MessageSvc.h.

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

Definition at line 186 of file MessageSvc.h.

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 150 of file MessageSvc.h.

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

Definition at line 200 of file MessageSvc.h.

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 177 of file MessageSvc.h.

MessageMap MessageSvc::m_messageMap
| private

Message map.

Definition at line 183 of file MessageSvc.h.

std::recursive_mutex MessageSvc::m_messageMapMutex
| mutable private

Mutex to synchronize multiple access to m_messageMap.

Definition at line 216 of file MessageSvc.h.

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

Definition at line 198 of file MessageSvc.h.

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 159 of file MessageSvc.h.

std::recursive_mutex MessageSvc::m_reportMutex
| mutable private

Mutex to synchronize multiple threads printing.

Definition at line 213 of file MessageSvc.h.

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

Definition at line 196 of file MessageSvc.h.

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

Definition at line 137 of file MessageSvc.h.

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

Definition at line 136 of file MessageSvc.h.

StreamMap MessageSvc::m_streamMap
| private

Stream map.

Definition at line 182 of file MessageSvc.h.

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

Definition at line 168 of file MessageSvc.h.

ThresholdMap MessageSvc::m_thresholdMap
| private

Output level threshold map.

Definition at line 184 of file MessageSvc.h.

std::recursive_mutex MessageSvc::m_thresholdMapMutex
| mutable private

Mutex to synchronize multiple access to m_thresholdMap (.

See also
  MsgStream::doOutput).

Definition at line 220 of file MessageSvc.h.

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 139 of file MessageSvc.h.

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 171 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