| The Gaudi Framework v27r1

- 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 Types | 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 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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. 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 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Private Types
typedef std::map< std::string, MSG::Color > | ColorMap

## Private Member Functions
std::string | colTrans (std::string, int)
void | initColors (Property &prop)
void | setupColors (Property &prop)
void | setupLimits (Property &prop)
void | setupThreshold (Property &prop)
void | setupInactCount (Property &prop)
void | setupLogStreams ()
void | tee (const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)

## Private Attributes
std::ostream * | m_defaultStream
| 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_defaultFormat
| Default format for the messages. More...
std::string | m_defaultTimeFormat
| Default format for timestamps in the messages. More...
StringArrayProperty | m_thresholdProp [MSG::NUM_LEVELS]
| Properties controlling. More...
BooleanProperty | m_color
BooleanProperty | m_stats
UnsignedIntegerProperty | m_statLevel
StringArrayProperty | m_logColors [MSG::NUM_LEVELS]
IntegerProperty | m_msgLimit [MSG::NUM_LEVELS]
std::string | m_logColorCodes [MSG::NUM_LEVELS]
std::map< std::string, MsgAry > | m_sourceMap
std::map< std::string, MsgAry > | m_inactiveMap
BooleanProperty | m_suppress
BooleanProperty | m_inactCount
std::vector< std::string > | m_tracedInactiveSources
ColorMap | m_colMap
std::array< int, MSG::NUM_LEVELS > | m_msgCount
std::map< std::string, std::string > | m_loggedStreamsName
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
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...

## Detailed Description

Definition at line 30 of file MessageSvc.h.

## Member Typedef Documentation

typedef std::map<std::string, MSG::Color> MessageSvc::ColorMap
| private

Definition at line 167 of file MessageSvc.h.

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

Definition at line 36 of file MessageSvc.h.

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

Definition at line 34 of file MessageSvc.h.

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

Definition at line 35 of file MessageSvc.h.

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

Definition at line 37 of file MessageSvc.h.

## Constructor & Destructor Documentation

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

Definition at line 58 of file MessageSvc.cpp.

59 : base_class( name, svcloc ) {
60 m_defaultStream = &std::cout;
61 declareProperty( "Format", m_defaultFormat = Message::getDefaultFormat() );
62 declareProperty( "timeFormat", m_defaultTimeFormat = Message::getDefaultTimeFormat() );
63 declareProperty( "showStats", m_stats = false );
64 declareProperty( "statLevel", m_statLevel = 0 );
65
66 // Special properties to control output level of individual sources
67 declareProperty( "setVerbose", m_thresholdProp[MSG::VERBOSE] );
68 declareProperty( "setDebug", m_thresholdProp[MSG::DEBUG] );
69 declareProperty( "setInfo", m_thresholdProp[MSG::INFO] );
70 declareProperty( "setWarning", m_thresholdProp[MSG::WARNING] );
71 declareProperty( "setError", m_thresholdProp[MSG::ERROR] );
72 declareProperty( "setFatal", m_thresholdProp[MSG::FATAL] );
73 declareProperty( "setAlways", m_thresholdProp[MSG::ALWAYS] );
74
75 declareProperty( "useColors", m_color=false)->declareUpdateHandler(&MessageSvc::initColors, this);
76
77 declareProperty( "fatalColorCode", m_logColors[MSG::FATAL] );
78 declareProperty( "errorColorCode", m_logColors[MSG::ERROR] );
79 declareProperty( "warningColorCode", m_logColors[MSG::WARNING] );
80 declareProperty( "infoColorCode", m_logColors[MSG::INFO] );
81 declareProperty( "debugColorCode", m_logColors[MSG::DEBUG] );
82 declareProperty( "verboseColorCode", m_logColors[MSG::VERBOSE] );
83 declareProperty( "alwaysColorCode", m_logColors[MSG::ALWAYS] );
84
85 const int defaultLimit = 500;
86 declareProperty( "fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
87 declareProperty( "errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
88 declareProperty( "warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
89 declareProperty( "infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
90 declareProperty( "debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
91 declareProperty( "verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
92 declareProperty( "alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
93
94 declareProperty( "defaultLimit", m_msgLimit[MSG::NIL] = defaultLimit );
95
96 declareProperty( "enableSuppression", m_suppress = false );
97 declareProperty( "countInactive", m_inactCount = false )->declareUpdateHandler( &MessageSvc::setupInactCount, this );
98 declareProperty( "tracedInactiveSources", m_tracedInactiveSources,
99 "for each message source specified, print a stack trace for"
100 "the unprotected and unseen messages" );
101 #ifndef NDEBUG
102 // initialize the MsgStream static flag.
103 MsgStream::enableCountInactive(m_inactCount);
104 #endif
105
106 declareProperty( "loggedStreams",
107 m_loggedStreamsName,
108 "MessageStream sources we want to dump into a logfile" );
109
110 for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
111 m_logColors[ic].declareUpdateHandler(&MessageSvc::setupColors, this);
112 m_msgLimit[ic].declareUpdateHandler(&MessageSvc::setupLimits, this);
113 m_thresholdProp[ic].declareUpdateHandler(&MessageSvc::setupThreshold, this);
114 }
115
116 std::fill( std::begin(m_msgCount),std::end(m_msgCount), 0 );
117 }
MessageSvc::m_msgLimit
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:150
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:138
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:170
Property::declareUpdateHandler
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
MSG::DEBUG
Definition: IMessageSvc.h:18
MessageSvc::setupLimits
void setupLimits(Property &prop)
Definition: MessageSvc.cpp:245
MessageSvc::setupInactCount
void setupInactCount(Property &prop)
Definition: MessageSvc.cpp:309
std::end
T end(T...args)
extends< Service, IMessageSvc, IInactiveMessageCounter >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
MSG::VERBOSE
Definition: IMessageSvc.h:17
MessageSvc::m_statLevel
UnsignedIntegerProperty m_statLevel
Definition: MessageSvc.h:148
MSG::FATAL
Definition: IMessageSvc.h:22
Message::getDefaultTimeFormat
static const std::string getDefaultTimeFormat()
Get the default time format string.
Definition: Message.cpp:226
Message::getDefaultFormat
static const std::string getDefaultFormat()
Get the default format string.
Definition: Message.cpp:187
MSG::NIL
Definition: IMessageSvc.h:16
MessageSvc::m_thresholdProp
StringArrayProperty m_thresholdProp[MSG::NUM_LEVELS]
Properties controlling.
Definition: MessageSvc.h:145
std::begin
T begin(T...args)
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MessageSvc::m_defaultFormat
std::string m_defaultFormat
Default format for the messages.
Definition: MessageSvc.h:143
MessageSvc::setupColors
void setupColors(Property &prop)
Definition: MessageSvc.cpp:195
MessageSvc::initColors
void initColors(Property &prop)
Definition: MessageSvc.cpp:165
MSG::ERROR
Definition: IMessageSvc.h:21
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146
MSG::WARNING
Definition: IMessageSvc.h:20
MessageSvc::m_inactCount
BooleanProperty m_inactCount
Definition: MessageSvc.h:163
std::fill
T fill(T...args)
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
MessageSvc::m_stats
BooleanProperty m_stats
Definition: MessageSvc.h:147
MessageSvc::m_loggedStreamsName
std::map< std::string, std::string > m_loggedStreamsName
Definition: MessageSvc.h:172
MSG::INFO
Definition: IMessageSvc.h:19
MessageSvc::m_tracedInactiveSources
std::vector< std::string > m_tracedInactiveSources
Definition: MessageSvc.h:164
MessageSvc::m_suppress
BooleanProperty m_suppress
Definition: MessageSvc.h:163
std::cout
MessageSvc::setupThreshold
void setupThreshold(Property &prop)
Definition: MessageSvc.cpp:272
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32
MessageSvc::m_defaultTimeFormat
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
Definition: MessageSvc.h:144
MSG::ALWAYS
Definition: IMessageSvc.h:23
MessageSvc::m_logColors
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:149

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

## Member Function Documentation

std::string MessageSvc::colTrans | ( | std::string | col,
|  | int | offset
| ) |  |
| private

Definition at line 434 of file MessageSvc.cpp.

434 {
435 auto itr = m_colMap.find(col);
436 int icol = offset + ( (itr != m_colMap.end()) ? itr->second : 8 );
437 return std::to_string( icol );
438 }
MessageSvc::m_colMap
ColorMap m_colMap
Definition: MessageSvc.h:168
std::to_string
T to_string(T...args)
std::map::end
T end(T...args)
std::map::find
T find(T...args)

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

Definition at line 94 of file MessageSvc.h.

94 {
95 return m_defaultStream;
96 }
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:138

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

Definition at line 658 of file MessageSvc.cpp.

659 {
660 std::unique_lock<std::recursive_mutex> lock(m_messageMapMutex);
661 m_messageMap.clear();
662 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
locker.lock
def lock(file)
Definition: locker.py:16
std::multimap::clear
T clear(T...args)
std::unique_lock

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

Definition at line 671 of file MessageSvc.cpp.

672 {
673 std::unique_lock<std::recursive_mutex> lock(m_messageMapMutex);
674 m_messageMap.erase( key );
675 }
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
std::multimap::erase
T erase(T...args)
locker.lock
def lock(file)
Definition: locker.py:16
std::unique_lock

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

Definition at line 684 of file MessageSvc.cpp.

685 {
686 std::unique_lock<std::recursive_mutex> lock(m_messageMapMutex);
687
688 erase_if( m_messageMap, m_messageMap.equal_range(key),
689 [&](MessageMap::const_reference j) { return j.second==msg; } ) ;
690 }
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:133
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
locker.lock
def lock(file)
Definition: locker.py:16
std::unique_lock
std::multimap::equal_range
T equal_range(T...args)

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

Definition at line 592 of file MessageSvc.cpp.

593 {
594 m_streamMap.clear();
595 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
std::multimap::clear
T clear(T...args)

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

Definition at line 604 of file MessageSvc.cpp.

605 {
606 m_streamMap.erase( message_type );
607 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
std::multimap::erase
T erase(T...args)

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

Definition at line 616 of file MessageSvc.cpp.

616 {
617 if ( stream ) {
618 erase_if( m_streamMap, m_streamMap.equal_range(key),
619 [&](StreamMap::const_reference j)
620 { return j.second.second == stream; } );
621 }
622 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
std::multimap::equal_range
T equal_range(T...args)

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

Definition at line 631 of file MessageSvc.cpp.

631 {
632 if ( stream ) {
633 erase_if( m_streamMap, [&](StreamMap::const_reference j)
634 { return j.second.second == stream; } );
635 }
636 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140

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

Finalize Service.

Definition at line 321 of file MessageSvc.cpp.

321 {
322
323 m_suppress = false;
324
325 {
326 std::ostringstream os;
327
328 if (m_stats) {
329 os << "Summarizing all message counts" << std::endl;
330 } else {
331 os << "Listing sources of suppressed message: " << std::endl;
332 }
333
334 os << "=====================================================" << std::endl;
335 os << " Message Source | Level | Count" << std::endl;
336 os << "-----------------------------+---------+-------------" << std::endl;
337
338
339 bool found(false);
340
341 for (auto itr=m_sourceMap.begin(); itr!=m_sourceMap.end(); ++itr) {
342 for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
343 if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
344 (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
345 os << " ";
346 os.width(28);
347 os.setf(std::ios_base::left,std::ios_base::adjustfield);
348 os << itr->first;
349 os << "|";
350
351 os.width(8);
352 os.setf(std::ios_base::right,std::ios_base::adjustfield);
353 os << levelNames[ic];
354 os << " |";
355
356 os.width(9);
357 os << itr->second.msg[ic];
358 os << std::endl;
359
360 found = true;
361 }
362 }
363 }
364 os << "=====================================================" << std::endl;
365 if (found || m_stats) std::cout << os.str();
366 }
367
368 #ifndef NDEBUG
369 if (m_inactCount.value()) {
370
371 std::ostringstream os;
372 os << "Listing sources of Unprotected and Unseen messages\n";
373
374 bool found(false);
375
376 unsigned int ml(0);
377 for (const auto& itr : m_inactiveMap) {
378 for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
379 if (itr.second.msg[ic] != 0 && itr.first.length() > ml) {
380 ml = itr.first.length();
381 }
382 }
383 }
384
385 for (unsigned int i=0; i<ml+25; ++i) os << "=";
386
387 os << std::endl << " ";
388 os.width(ml+2);
389 os.setf(std::ios_base::left,std::ios_base::adjustfield);
390 os << "Message Source";
391 os.width(1);
392 os << "| Level | Count" << std::endl;
393
394 for (unsigned int i=0; i<ml+3; ++i) os << "-";
395 os << "+---------+-----------" << std::endl;
396
397
398 for (auto itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
399 for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
400 if (itr->second.msg[ic] != 0) {
401 os << " ";
402 os.width(ml+2);
403 os.setf(std::ios_base::left,std::ios_base::adjustfield);
404 os << itr->first;
405
406 os << "|";
407
408 os.width(8);
409 os.setf(std::ios_base::right,std::ios_base::adjustfield);
410 os << levelNames[ic];
411
412 os << " |";
413
414 os.width(9);
415 os << itr->second.msg[ic];
416
417 os << std::endl;
418
419 found = true;
420 }
421 }
422 }
423 for (unsigned int i=0; i<ml+25; ++i) os << "=";
424 os << std::endl;
425
426 if (found) std::cout << os.str();
427 }
428 #endif
429
430 return StatusCode::SUCCESS;
431 }
MessageSvc::m_msgLimit
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:150
std::ostringstream::setf
T setf(T...args)
std::endl
T endl(T...args)
MessageSvc::m_statLevel
UnsignedIntegerProperty m_statLevel
Definition: MessageSvc.h:148
MessageSvc::m_sourceMap
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:162
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::ostringstream
STL class.
std::ostringstream::width
T width(T...args)
std::ostringstream::str
T str(T...args)
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MessageSvc::m_inactiveMap
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:162
MessageSvc::m_inactCount
BooleanProperty m_inactCount
Definition: MessageSvc.h:163
MessageSvc::m_stats
BooleanProperty m_stats
Definition: MessageSvc.h:147
ana.i
list i
Definition: ana.py:128
std::cout
MessageSvc::m_suppress
BooleanProperty m_suppress
Definition: MessageSvc.h:163

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

Definition at line 727 of file MessageSvc.cpp.

727 {
728 // ---------------------------------------------------------------------------
729 return (logLevel < MSG::NUM_LEVELS) ? m_logColorCodes[logLevel] : "" ;
730 }
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:152

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

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

Definition at line 451 of file MessageSvc.cpp.

451 {
452 int key = msg.getType();
453
454 ++m_msgCount[key];
455
456 const Message *cmsg = &msg;
457
458 // processing logged streams
459 if ( !m_loggedStreams.empty() ) {
460 auto iLog = m_loggedStreams.find( msg.getSource() );
461 if ( m_loggedStreams.end() != iLog ) {
462 (*iLog->second) << *cmsg << std::endl;
463 }
464 }
465
466 if ( m_suppress.value() || m_stats.value() ) {
467
468 // Increase the counter of 'key' type of messages for the source and
469 // get the new value.
470 const int nmsg = ++(m_sourceMap[msg.getSource()].msg[key]);
471
472 if (m_suppress.value() && m_msgLimit[key] != 0 ) {
473 if (nmsg > m_msgLimit[key]) return;
474 if (nmsg == m_msgLimit[key]) {
475 std::string txt = levelNames[key] + " message limit ("
476 + std::to_string( m_msgLimit[key].value() )
477 + ") reached for " + msg.getSource() + ". Suppressing further output.";
478 cmsg = new Message(msg.getSource(), MSG::WARNING, std::move(txt));
479 cmsg->setFormat(msg.getFormat());
480 }
481 }
482 }
483
484 auto range = m_streamMap.equal_range( key );
485 if ( range.first != m_streamMap.end() ) {
486 std::for_each( range.first,range.second, [&](StreamMap::const_reference sm) {
487 *sm.second.second << *cmsg << std::endl;
488 });
489 } else if ( key >= outputLevel ) {
490 msg.setFormat(m_defaultFormat);
491 msg.setTimeFormat(m_defaultTimeFormat);
492 if (!m_color) {
493 (*m_defaultStream) << *cmsg << std::endl << std::flush;
494 } else {
495 (*m_defaultStream) << m_logColorCodes[key] << *cmsg << "\033[m"
496 << std::endl << std::flush;
497 }
498 }
499
500 if (cmsg != &msg) { delete cmsg; }
501
502 }
MessageSvc::m_msgLimit
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:150
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:133
std::map::empty
T empty(T...args)
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:170
std::to_string
T to_string(T...args)
std::endl
T endl(T...args)
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:173
MessageSvc::m_sourceMap
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:162
Gaudi::range
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:130
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
std::move
T move(T...args)
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
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:14
MessageSvc::m_defaultFormat
std::string m_defaultFormat
Default format for the messages.
Definition: MessageSvc.h:143
Message::setTimeFormat
void setTimeFormat(std::string timeFormat) const
Set the time format string.
Definition: Message.cpp:239
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:152
Message::getSource
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:115
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146
MSG::WARNING
Definition: IMessageSvc.h:20
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:693
MessageSvc::m_stats
BooleanProperty m_stats
Definition: MessageSvc.h:147
std::for_each
T for_each(T...args)
MessageSvc::m_suppress
BooleanProperty m_suppress
Definition: MessageSvc.h:163
MessageSvc::m_defaultTimeFormat
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
Definition: MessageSvc.h:144
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 551 of file MessageSvc.cpp.

553 {
554 int level = outputLevel(source);
555 auto report = [&](Message mesg) {
556 mesg.setSource( source );
557 Message stat_code( source, mesg.getType(), "Status Code " + std::to_string( code.getCode() ) );
558 i_reportMessage( std::move(stat_code), level );
559 i_reportMessage( std::move(mesg), level );
560 };
561
562 auto range = m_messageMap.equal_range( code );
563 if ( range.first != m_messageMap.end() ) {
564 std::for_each( range.first, range.second,
565 [&](MessageMap::const_reference sm) { report(sm.second); } );
566 } else {
567 report(m_defaultMessage);
568 }
569 }
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:451
MessageSvc::m_defaultMessage
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:139
std::to_string
T to_string(T...args)
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
std::multimap::end
T end(T...args)
Gaudi::range
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
Definition: NamedRange.h:130
std::move
T move(T...args)
Message
The Message class.
Definition: Message.h:14
gaudirun.level
level
Definition: gaudirun.py:261
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:693
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 741 of file MessageSvc.cpp.

741 {
742 ++(m_inactiveMap[source].msg[level]);
743
744 if (std::find(begin(m_tracedInactiveSources),
745 end(m_tracedInactiveSources),
746 source) != end(m_tracedInactiveSources)) {
747 std::cout << "== inactive message detected from "
748 << source << " ==" << std::endl;
749 std::string t;
750 System::backTrace(t, 25, 0);
751 std::cout << t << std::endl;
752 }
753 }
std::endl
T endl(T...args)
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
std::string
STL class.
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::find
T find(T...args)
MessageSvc::m_inactiveMap
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:162
gaudirun.level
level
Definition: gaudirun.py:261
MessageSvc::m_tracedInactiveSources
std::vector< std::string > m_tracedInactiveSources
Definition: MessageSvc.h:164
std::cout

void MessageSvc::initColors | ( | Property & | prop | ) |
| private

Definition at line 165 of file MessageSvc.cpp.

165 {
166
167 if (m_color) {
168 static const std::array<std::pair<MSG::Level,std::vector<std::string>>,3> tbl{
169 { { MSG::FATAL, { { "[94;101;1m" } } },
170 { MSG::ERROR, { { "[97;101;1m" } } },
171 { MSG::WARNING, { { "[93;1m" } } } } };
172
173 for (const auto& p : tbl ) {
174 auto &lC = m_logColors[p.first];
175 if (lC.value().empty()) {
176 lC.set(p.second);
177 } else {
178 MessageSvc::setupColors( lC );
179 }
180 }
181
182 } else {
183
184 // reset all color codes;
185 for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
186 m_logColors[ic].set( { } );
187 }
188
189 }
190
191 }
PropertyWithVerifier::set
bool set(const TYPE &value)
update the value of the property/check the verifier
Definition: Property.h:434
MSG::FATAL
Definition: IMessageSvc.h:22
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MessageSvc::setupColors
void setupColors(Property &prop)
Definition: MessageSvc.cpp:195
std::array
STL class.
MSG::ERROR
Definition: IMessageSvc.h:21
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146
MSG::WARNING
Definition: IMessageSvc.h:20
MessageSvc::m_logColors
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:149

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

Initialize Service.

Definition at line 123 of file MessageSvc.cpp.

123 {
124 StatusCode sc;
125 sc = Service::initialize();
126 if( sc.isFailure() ) return sc;
127 // Set my own properties
128 sc = setProperties();
129 if (sc.isFailure()) return sc;
130
131 #ifdef _WIN32
132 m_color = false;
133 #endif
134
135 //NOTE: m_colMap is used _before_ it is filled here,
136 // i.e. while it is still empty.
137 // Moving this initialization 'up' by eg. just
138 // having a 'static const' colMap does not leave
139 // the results invariant...
140 m_colMap["black"] = MSG::BLACK;
141 m_colMap["red"] = MSG::RED;
142 m_colMap["green"] = MSG::GREEN;
143 m_colMap["yellow"] = MSG::YELLOW;
144 m_colMap["blue"] = MSG::BLUE;
145 m_colMap["purple"] = MSG::PURPLE;
146 m_colMap["cyan"] = MSG::CYAN;
147 m_colMap["white"] = MSG::WHITE;
148
149 // make sure the map of logged stream names is initialized
150 setupLogStreams();
151
152 return StatusCode::SUCCESS;
153 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
MessageSvc::m_colMap
ColorMap m_colMap
Definition: MessageSvc.h:168
MSG::CYAN
Definition: IMessageSvc.h:33
MSG::GREEN
Definition: IMessageSvc.h:29
MessageSvc::setupLogStreams
void setupLogStreams()
Definition: MessageSvc.cpp:756
MSG::WHITE
Definition: IMessageSvc.h:34
merge_files.sc
int sc
Definition: merge_files.py:167
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MSG::RED
Definition: IMessageSvc.h:28
MSG::BLUE
Definition: IMessageSvc.h:31
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
MSG::BLACK
Definition: IMessageSvc.h:27
MSG::PURPLE
Definition: IMessageSvc.h:32
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146
MSG::YELLOW
Definition: IMessageSvc.h:30

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

Definition at line 645 of file MessageSvc.cpp.

646 {
647 std::unique_lock<std::recursive_mutex> lock(m_messageMapMutex);
648 m_messageMap.emplace( key, msg );
649 }
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:133
MessageSvc::m_messageMap
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:141
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
locker.lock
def lock(file)
Definition: locker.py:16
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 578 of file MessageSvc.cpp.

581 {
582 m_streamMap.emplace( key, NamedStream(name,stream) );
583 }
MessageSvc::m_streamMap
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:140
MessageSvc::NamedStream
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:34
std::multimap::emplace
T emplace(T...args)

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

Definition at line 733 of file MessageSvc.cpp.

733 {
734
735 return m_msgCount[level];
736
737 }
MessageSvc::m_msgCount
std::array< int, MSG::NUM_LEVELS > m_msgCount
Definition: MessageSvc.h:170
gaudirun.level
level
Definition: gaudirun.py:261

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

Definition at line 693 of file MessageSvc.cpp.

693 {
694 // ---------------------------------------------------------------------------
695 return m_outputLevel;
696 }
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309

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

Definition at line 699 of file MessageSvc.cpp.

699 {
700 // ---------------------------------------------------------------------------
701 std::unique_lock<std::recursive_mutex> lock(m_thresholdMapMutex);
702 auto it = m_thresholdMap.find( source );
703 return it != m_thresholdMap.end() ? it->second : m_outputLevel.value();
704 }
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
std::map::end
T end(T...args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:142
locker.lock
def lock(file)
Definition: locker.py:16
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
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:194

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

Reinitialize Service.

Definition at line 158 of file MessageSvc.cpp.

158 {
159 m_state = Gaudi::StateMachine::OFFLINE;
160 return initialize();
161 }
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
MessageSvc::initialize
StatusCode initialize() override
Initialize Service.
Definition: MessageSvc.cpp:123
Gaudi::StateMachine::OFFLINE
Definition: StateMachine.h:13

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

Definition at line 510 of file MessageSvc.cpp.

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

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

Definition at line 446 of file MessageSvc.cpp.

446 {
447 std::unique_lock<std::recursive_mutex> lock(m_reportMutex);
448 i_reportMessage(msg, outputLevel);
449 }
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:451
locker.lock
def lock(file)
Definition: locker.py:16
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:187
std::unique_lock
MessageSvc::outputLevel
int outputLevel() const override
Definition: MessageSvc.cpp:693

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

Definition at line 544 of file MessageSvc.cpp.

546 {
547 std::unique_lock<std::recursive_mutex> lock(m_messageMapMutex);
548 i_reportMessage(code, source);
549 }
MessageSvc::i_reportMessage
virtual void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
Definition: MessageSvc.cpp:451
MessageSvc::m_messageMapMutex
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
locker.lock
def lock(file)
Definition: locker.py:16
std::unique_lock

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

Definition at line 520 of file MessageSvc.cpp.

522 {
523 reportMessage( Message{ source, type, message } );
524 }
gaudirun.type
string type
Definition: gaudirun.py:151
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:510
Message
The Message class.
Definition: Message.h:14

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

Definition at line 532 of file MessageSvc.cpp.

534 {
535 reportMessage( Message{source, type, message} );
536 }
gaudirun.type
string type
Definition: gaudirun.py:151
MessageSvc::reportMessage
void reportMessage(const Message &message) override
Definition: MessageSvc.cpp:510
Message
The Message class.
Definition: Message.h:14

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

Definition at line 99 of file MessageSvc.h.

99 {
100 std::unique_lock<std::recursive_mutex> lock(m_reportMutex);
101 m_defaultStream = stream;
102 }
MessageSvc::m_defaultStream
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:138
locker.lock
def lock(file)
Definition: locker.py:16
MessageSvc::m_reportMutex
std::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:187
std::unique_lock

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

Definition at line 707 of file MessageSvc.cpp.

707 {
708 // ---------------------------------------------------------------------------
709 m_outputLevel = new_level;
710 }
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309

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

Definition at line 713 of file MessageSvc.cpp.

713 {
714 // ---------------------------------------------------------------------------
715 std::unique_lock<std::recursive_mutex> lock(m_thresholdMapMutex);
716
717 // only write if we really have to...
718 auto i = m_thresholdMap.find( source );
719 if (i == m_thresholdMap.end()) {
720 m_thresholdMap[source] = level;
721 } else if (i->second!=level) {
722 i->second = level;
723 }
724 }
std::map::end
T end(T...args)
MessageSvc::m_thresholdMap
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:142
locker.lock
def lock(file)
Definition: locker.py:16
std::map::find
T find(T...args)
std::unique_lock
gaudirun.level
level
Definition: gaudirun.py:261
ana.i
list i
Definition: ana.py:128
MessageSvc::m_thresholdMapMutex
std::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:194

void MessageSvc::setupColors | ( | Property & | prop | ) |
| private

Definition at line 195 of file MessageSvc.cpp.

195 {
196
197 if (! m_color) return;
198
199 static const std::array<std::pair<const char*,MSG::Level>,7> tbl {
200 { {"fatalColorCode", MSG::FATAL },
201 {"errorColorCode", MSG::ERROR },
202 {"warningColorCode", MSG::WARNING },
203 {"infoColorCode", MSG::INFO },
204 {"debugColorCode", MSG::DEBUG },
205 {"verboseColorCode", MSG::VERBOSE },
206 {"alwaysColorCode", MSG::ALWAYS } } };
207
208 auto i = std::find_if( std::begin(tbl),std::end(tbl),
209 [&](const std::pair<const char*,MSG::Level>& t) {
210 return prop.name() == t.first;
211 } );
212 if (i==std::end(tbl)) {
213 std::cout << "ERROR: Unknown message color parameter: " << prop.name()
214 << std::endl;
215 return;
216 }
217 int ic = i->second;
218
219 std::string code;
220 auto itr = m_logColors[ic].value().begin();
221
222 if ( m_logColors[ic].value().size() == 1 ) {
223
224 if (itr->empty()) {
225 code = "";
226 } else if (itr->compare(0,1,"[") == 0) {
227 code = "\033" + *itr;
228 } else {
229 code = "\033[" + colTrans(*itr, 90) + ";1m";
230 }
231
232 } else if (m_logColors[ic].value().size() == 2) {
233 auto itr2 = itr + 1;
234
235 code = "\033[" + colTrans(*itr, 90) + ";"
236 + colTrans(*itr2, 100) + ";1m";
237
238 }
239
240 m_logColorCodes[ic] = code;
241
242 }
MessageSvc::colTrans
std::string colTrans(std::string, int)
Definition: MessageSvc.cpp:434
Property::name
const std::string & name() const
property name
Definition: Property.h:45
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
std::end
T end(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:17
std::string
STL class.
MSG::FATAL
Definition: IMessageSvc.h:22
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
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
MessageSvc::m_logColorCodes
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:152
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146
MSG::WARNING
Definition: IMessageSvc.h:20
MSG::INFO
Definition: IMessageSvc.h:19
ana.i
list i
Definition: ana.py:128
std::cout
MSG::ALWAYS
Definition: IMessageSvc.h:23
MessageSvc::m_logColors
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:149

void MessageSvc::setupInactCount | ( | Property & | prop | ) |
| private

Definition at line 309 of file MessageSvc.cpp.

309 {
310 if (prop.name() == "countInactive") {
311 BooleanProperty *p = dynamic_cast<BooleanProperty*>(&prop);
312 if (p)
313 MsgStream::enableCountInactive(p->value());
314 }
315 }
Property::name
const std::string & name() const
property name
Definition: Property.h:45
SimpleProperty< bool >
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
MsgStream::enableCountInactive
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32

void MessageSvc::setupLimits | ( | Property & | prop | ) |
| private

Definition at line 245 of file MessageSvc.cpp.

245 {
246 // Just report problems in the settings of the limits and unknown limit parameters
247 if (prop.name() == "alwaysLimit") {
248 IntegerProperty *p = dynamic_cast<IntegerProperty*>(&prop);
249 if (p && p->value() != 0) {
250 std::cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << std::endl;
251 p->setValue(0);
252 }
253 } else if (prop.name() == "defaultLimit") {
254 for (int i = MSG::VERBOSE; i< MSG::NUM_LEVELS; ++i) {
255 if (i != MSG::ALWAYS) {
256 m_msgLimit[i] = m_msgLimit[MSG::NIL].value();
257 }
258 }
259 } else if (prop.name() != "fatalLimit" &&
260 prop.name() != "errorLimit" &&
261 prop.name() != "warningLimit" &&
262 prop.name() == "infoLimit" &&
263 prop.name() == "debugLimit" &&
264 prop.name() == "verboseLimit") {
265 std::cout << "MessageSvc ERROR: Unknown message limit parameter: "
266 << prop.name() << std::endl;
267 return;
268 }
269 }
MessageSvc::m_msgLimit
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:150
Property::name
const std::string & name() const
property name
Definition: Property.h:45
std::endl
T endl(T...args)
PropertyWithVerifier::setValue
bool setValue(const TYPE &value) override
implementation of PropertyWithValue::setValue
Definition: Property.h:406
MSG::VERBOSE
Definition: IMessageSvc.h:17
SimpleProperty< int >
MSG::NIL
Definition: IMessageSvc.h:16
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
ana.i
list i
Definition: ana.py:128
std::cout
MSG::ALWAYS
Definition: IMessageSvc.h:23

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

Definition at line 756 of file MessageSvc.cpp.

757 {
758 // reset state
759 m_loggedStreams.clear();
760
761 for ( auto& iProp : m_loggedStreamsName ) {
762
763 std::set<std::string> outFileNames;
764 for ( auto& jProp : m_loggedStreamsName ) {
765 if ( jProp.first != iProp.first ) {
766 outFileNames.insert( jProp.second );
767 }
768 }
769 tee( iProp.first, iProp.second, outFileNames );
770
771 }//> loop over property entries
772 }
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:173
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:775
MessageSvc::m_loggedStreamsName
std::map< std::string, std::string > m_loggedStreamsName
Definition: MessageSvc.h:172

void MessageSvc::setupThreshold | ( | Property & | prop | ) |
| private

Definition at line 272 of file MessageSvc.cpp.

272 {
273
274 static const std::array<std::pair<const char*,MSG::Level>,7> tbl{
275 { { "setFatal", MSG::FATAL },
276 { "setError", MSG::ERROR },
277 { "setWarning", MSG::WARNING },
278 { "setInfo", MSG::INFO },
279 { "setDebug", MSG::DEBUG },
280 { "setVerbose", MSG::VERBOSE },
281 { "setAlways", MSG::ALWAYS } } };
282
283 auto i = std::find_if( std::begin(tbl),std::end(tbl),
284 [&](const std::pair<const char*,MSG::Level>& t) {
285 return prop.name() == t.first;
286 } );
287 if (i==std::end(tbl)) {
288 std::cerr << "MessageSvc ERROR: Unknown message threshold parameter: "
289 << prop.name() << std::endl;
290 return;
291 }
292 int ic = i->second;
293
294 StringArrayProperty *sap = dynamic_cast<StringArrayProperty*>( &prop);
295 if (!sap) {
296 std::cerr << "could not dcast " << prop.name()
297 << " to a StringArrayProperty (which it should be!)" << std::endl;
298 } else {
299 for ( auto& i : sap->value() ) setOutputLevel( i, ic );
300 }
301
302 }
Property::name
const std::string & name() const
property name
Definition: Property.h:45
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
std::end
T end(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:17
SimpleProperty< std::vector< std::string > >
MSG::FATAL
Definition: IMessageSvc.h:22
MessageSvc::setOutputLevel
void setOutputLevel(int new_level) override
Definition: MessageSvc.cpp:707
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
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
MSG::INFO
Definition: IMessageSvc.h:19
ana.i
list i
Definition: ana.py:128
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 775 of file MessageSvc.cpp.

778 {
779 const std::ios_base::openmode openMode = std::ios_base::out |
780 std::ios_base::trunc;
781
782 auto iStream = m_loggedStreams.find( sourceName );
783 if ( iStream != std::end(m_loggedStreams) ) {
784 m_loggedStreams.erase( iStream );
785 }
786
787 // before creating a new ofstream, make sure there is no already existing
788 // one with the same file name...
789 for (auto& iStream : m_loggedStreams ) {
790 if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
791 m_loggedStreams[sourceName] = m_loggedStreams[iStream.first];
792 return;
793 }
794 }
795
796 auto out = std::make_shared<std::ofstream>( outFileName, openMode );
797 if ( out->good() ) m_loggedStreams[sourceName] = std::move(out);
798
799 }
std::end
T end(T...args)
MessageSvc::m_loggedStreams
std::map< std::string, std::shared_ptr< std::ostream > > m_loggedStreams
Definition: MessageSvc.h:173
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 117 of file MessageSvc.h.

117 { return m_color; }
MessageSvc::m_color
BooleanProperty m_color
Definition: MessageSvc.h:146

## Member Data Documentation

ColorMap MessageSvc::m_colMap
| private

Definition at line 168 of file MessageSvc.h.

BooleanProperty MessageSvc::m_color
| private

Definition at line 146 of file MessageSvc.h.

std::string MessageSvc::m_defaultFormat
| private

Default format for the messages.

Definition at line 143 of file MessageSvc.h.

Message MessageSvc::m_defaultMessage
| private

Default Message.

Definition at line 139 of file MessageSvc.h.

std::ostream* MessageSvc::m_defaultStream
| private

Pointer to the output stream.

Definition at line 138 of file MessageSvc.h.

std::string MessageSvc::m_defaultTimeFormat
| private

Default format for timestamps in the messages.

Definition at line 144 of file MessageSvc.h.

BooleanProperty MessageSvc::m_inactCount
| private

Definition at line 163 of file MessageSvc.h.

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

Definition at line 162 of file MessageSvc.h.

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

Definition at line 152 of file MessageSvc.h.

StringArrayProperty MessageSvc::m_logColors[MSG::NUM_LEVELS]
| private

Definition at line 149 of file MessageSvc.h.

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

Definition at line 173 of file MessageSvc.h.

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

Definition at line 172 of file MessageSvc.h.

MessageMap MessageSvc::m_messageMap
| private

Message map.

Definition at line 141 of file MessageSvc.h.

std::recursive_mutex MessageSvc::m_messageMapMutex
| mutable private

Mutex to synchronize multiple access to m_messageMap.

Definition at line 190 of file MessageSvc.h.

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

Definition at line 170 of file MessageSvc.h.

IntegerProperty MessageSvc::m_msgLimit[MSG::NUM_LEVELS]
| private

Definition at line 150 of file MessageSvc.h.

std::recursive_mutex MessageSvc::m_reportMutex
| mutable private

Mutex to synchronize multiple threads printing.

Definition at line 187 of file MessageSvc.h.

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

Definition at line 162 of file MessageSvc.h.

UnsignedIntegerProperty MessageSvc::m_statLevel
| private

Definition at line 148 of file MessageSvc.h.

BooleanProperty MessageSvc::m_stats
| private

Definition at line 147 of file MessageSvc.h.

StreamMap MessageSvc::m_streamMap
| private

Stream map.

Definition at line 140 of file MessageSvc.h.

BooleanProperty MessageSvc::m_suppress
| private

Definition at line 163 of file MessageSvc.h.

ThresholdMap MessageSvc::m_thresholdMap
| private

Output level threshold map.

Definition at line 142 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 194 of file MessageSvc.h.

StringArrayProperty MessageSvc::m_thresholdProp[MSG::NUM_LEVELS]
| private

Properties controlling.

Definition at line 145 of file MessageSvc.h.

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

Definition at line 164 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