All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MessageSvc Class Reference

#include <src/MessageSvc/MessageSvc.h>

Inheritance diagram for MessageSvc:
Collaboration diagram for MessageSvc:

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 extends2< Service, IMessageSvc, IInactiveMessageCounter >
typedef extends2 base_class
 Typedef to this class. More...
 
typedef extend_interfaces2
< IMessageSvc,
IInactiveMessageCounter
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory2
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces2< IMessageSvc, IInactiveMessageCounter >
typedef mpl::fold< typename
IMessageSvc::iid::iids::type,
typename
IInactiveMessageCounter::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 

Public Member Functions

 MessageSvc (const std::string &name, ISvcLocator *svcloc)
 
virtual ~MessageSvc ()
 
virtual StatusCode reinitialize ()
 Reinitialize Service. More...
 
virtual StatusCode initialize ()
 Initialize Service. More...
 
virtual StatusCode finalize ()
 Finalize Service. More...
 
virtual void reportMessage (const Message &message)
 Report a message by sending a Message object to the message service. More...
 
virtual void reportMessage (const Message &msg, int outputLevel)
 Report a message by sending a Message object to the message service. More...
 
virtual void reportMessage (const StatusCode &code, const std::string &source="")
 Report an error to the message service. More...
 
virtual void reportMessage (const char *source, int type, const char *message)
 Report a message by specifying the source, severity level and text. More...
 
virtual void reportMessage (const std::string &source, int type, const std::string &message)
 Report a message by specifying the source, severity level and text. More...
 
virtual void insertMessage (const StatusCode &code, const Message &message)
 Insert a message to be sent for a given status code into the error code repository. More...
 
virtual void eraseMessage ()
 Erase all messages associated to all status codes. More...
 
virtual void eraseMessage (const StatusCode &code)
 Erase message associated to a given status code. More...
 
virtual void eraseMessage (const StatusCode &code, const Message &message)
 Erase a given message associated to a given status code. More...
 
virtual void insertStream (int message_type, const std::string &name, std::ostream *stream)
 Add a new stream for a message type (severity level). More...
 
virtual void eraseStream ()
 Delete all the streams. More...
 
virtual void eraseStream (int message_type)
 Delete all the streams for a given message type (severity level). More...
 
virtual void eraseStream (int message_type, std::ostream *stream)
 Delete a single stream for a given message type (severity level) More...
 
virtual void eraseStream (std::ostream *stream)
 Delete all occurrences of a stream. More...
 
virtual std::ostream * defaultStream () const
 Get the default stream. More...
 
virtual void setDefaultStream (std::ostream *stream)
 Set the default stream. More...
 
virtual int outputLevel () const
 Retrieve the current output level threshold. More...
 
virtual int outputLevel (const std::string &source) const
 Retrieve the current output level threshold for a given message source. More...
 
virtual void setOutputLevel (int new_level)
 Set new global output level threshold. More...
 
virtual void setOutputLevel (const std::string &source, int new_level)
 Set new output level threshold for a given message source. More...
 
virtual bool useColor () const
 Show whether colors are used. More...
 
virtual std::string getLogColor (int logLevel) const
 Get the color codes for various log levels. More...
 
virtual int messageCount (MSG::Level logLevel) const
 Get the number of messages issued at a particular level. More...
 
virtual void incrInactiveCount (MSG::Level level, const std::string &src)
 Increment deactivated message count. More...
 
- Public Member Functions inherited from extends2< Service, IMessageSvc, IInactiveMessageCounter >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends2 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends2 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 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<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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces2< IMessageSvc, IInactiveMessageCounter >
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IMessageSvc
 DeclareInterfaceID (IMessageSvc, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IInactiveMessageCounter
 DeclareInterfaceID (IInactiveMessageCounter, 1, 0)
 InterfaceID. More...
 

Private Types

typedef std::map< std::string,
MSG::Color
ColorMap
 
typedef std::map< std::string,
std::ostream * > 
LoggedStreamsMap_t
 

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, MsgArym_sourceMap
 
std::map< std::string, MsgArym_inactiveMap
 
BooleanProperty m_suppress
 
BooleanProperty m_inactCount
 
ColorMap m_colMap
 
int m_msgCount [MSG::NUM_LEVELS]
 
std::map< std::string,
std::string > 
m_loggedStreamsName
 
LoggedStreamsMap_t m_loggedStreams
 
boost::recursive_mutex m_reportMutex
 Mutex to synchronize multiple threads printing. More...
 
boost::recursive_mutex m_messageMapMutex
 Mutex to synchronize multiple access to m_messageMap. More...
 
boost::recursive_mutex m_thresholdMapMutex
 Mutex to synchronize multiple access to m_thresholdMap (. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Definition at line 31 of file MessageSvc.h.

Member Typedef Documentation

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

Definition at line 166 of file MessageSvc.h.

typedef std::map<std::string, std::ostream*> MessageSvc::LoggedStreamsMap_t
private

Definition at line 172 of file MessageSvc.h.

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

27  : base_class( name, svcloc ) {
28  m_defaultStream = &std::cout;
32  declareProperty( "showStats", m_stats = false );
33  declareProperty( "statLevel", m_statLevel = 0 );
34 
35  // Special properties to control output level of individual sources
43 
44  declareProperty( "useColors", m_color=false);
46 
47  declareProperty( "fatalColorCode", m_logColors[MSG::FATAL] );
48  declareProperty( "errorColorCode", m_logColors[MSG::ERROR] );
49  declareProperty( "warningColorCode", m_logColors[MSG::WARNING] );
50  declareProperty( "infoColorCode", m_logColors[MSG::INFO] );
51  declareProperty( "debugColorCode", m_logColors[MSG::DEBUG] );
52  declareProperty( "verboseColorCode", m_logColors[MSG::VERBOSE] );
53  declareProperty( "alwaysColorCode", m_logColors[MSG::ALWAYS] );
54 
55  const int defaultLimit = 500;
56  declareProperty( "fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
57  declareProperty( "errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
58  declareProperty( "warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
59  declareProperty( "infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
60  declareProperty( "debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
61  declareProperty( "verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
62  declareProperty( "alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
63 
64  declareProperty( "defaultLimit", m_msgLimit[MSG::NIL] = defaultLimit );
65 
66  declareProperty( "enableSuppression", m_suppress = false );
68 #ifndef NDEBUG
69  // initialize the MsgStream static flag.
71 #endif
72 
73  declareProperty( "loggedStreams",
75  "MessageStream sources we want to dump into a logfile" );
76 
77  for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
81  }
82 
83  levelNames[0] = "NIL";
84  levelNames[1] = "VERBOSE";
85  levelNames[2] = "DEBUG";
86  levelNames[3] = "INFO";
87  levelNames[4] = "WARNING";
88  levelNames[5] = "ERROR";
89  levelNames[6] = "FATAL";
90  levelNames[7] = "ALWAYS";
91 
92  for (int i=0; i<MSG::NUM_LEVELS; ++i) {
93  m_msgCount[i] = 0;
94  }
95 
96 }
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:142
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:241
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:130
extends2 base_class
Typedef to this class.
Definition: extends.h:77
void setupLimits(Property &prop)
Definition: MessageSvc.cpp:249
void setupInactCount(Property &prop)
Definition: MessageSvc.cpp:320
int m_msgCount[MSG::NUM_LEVELS]
Definition: MessageSvc.h:169
UnsignedIntegerProperty m_statLevel
Definition: MessageSvc.h:140
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
Definition: Property.cpp:141
static const std::string getDefaultTimeFormat()
Get the default time format string.
Definition: Message.cpp:238
static const std::string getDefaultFormat()
Get the default format string.
Definition: Message.cpp:200
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
StringArrayProperty m_thresholdProp[MSG::NUM_LEVELS]
Properties controlling.
Definition: MessageSvc.h:137
std::string m_defaultFormat
Default format for the messages.
Definition: MessageSvc.h:135
void setupColors(Property &prop)
Definition: MessageSvc.cpp:197
void initColors(Property &prop)
Definition: MessageSvc.cpp:155
BooleanProperty m_color
Definition: MessageSvc.h:138
BooleanProperty m_inactCount
Definition: MessageSvc.h:163
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:209
BooleanProperty m_stats
Definition: MessageSvc.h:139
std::map< std::string, std::string > m_loggedStreamsName
Definition: MessageSvc.h:171
list i
Definition: ana.py:128
BooleanProperty m_suppress
Definition: MessageSvc.h:163
void setupThreshold(Property &prop)
Definition: MessageSvc.cpp:276
static GAUDI_API bool enableCountInactive(bool value=true)
Enable/disable the count of inactive messages.
Definition: MsgStream.cpp:32
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
Definition: MessageSvc.h:136
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:141
MessageSvc::~MessageSvc ( )
virtual

Definition at line 100 of file MessageSvc.cpp.

101 {
102  // closing log-files, if any
103  LoggedStreamsMap_t::iterator iStream = m_loggedStreams.begin();
104  LoggedStreamsMap_t::iterator endStream = m_loggedStreams.end();
105  for ( ; iStream != endStream; ++iStream ) {
106  delete iStream->second;
107  iStream->second = 0;
108  }
109 }
LoggedStreamsMap_t m_loggedStreams
Definition: MessageSvc.h:173

Member Function Documentation

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

Definition at line 461 of file MessageSvc.cpp.

461  {
462  ColorMap::const_iterator itr = m_colMap.find(col);
463  int icol;
464  if (itr != m_colMap.end()) {
465  icol = offset + itr->second;
466  } else {
467  icol = offset + 8;
468  }
469  std::ostringstream os1;
470 
471  os1 << icol;
472 
473  return os1.str();
474 
475 }
ColorMap m_colMap
Definition: MessageSvc.h:167
virtual std::ostream* MessageSvc::defaultStream ( ) const
inlinevirtual

Get the default stream.

Implements IMessageSvc.

Definition at line 93 of file MessageSvc.h.

93  {
94  return m_defaultStream;
95  }
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:130
void MessageSvc::eraseMessage ( )
virtual

Erase all messages associated to all status codes.

Implements IMessageSvc.

Definition at line 734 of file MessageSvc.cpp.

735 {
736  boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
737 
738  m_messageMap.erase( m_messageMap.begin(), m_messageMap.end() );
739 }
def lock
Definition: locker.py:16
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:133
boost::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
void MessageSvc::eraseMessage ( const StatusCode code)
virtual

Erase message associated to a given status code.

Implements IMessageSvc.

Definition at line 748 of file MessageSvc.cpp.

749 {
750  boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
751 
752  m_messageMap.erase( key );
753 }
def lock
Definition: locker.py:16
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:133
boost::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
void MessageSvc::eraseMessage ( const StatusCode code,
const Message message 
)
virtual

Erase a given message associated to a given status code.

Parameters
codeStatus error code
messageMessage associated

Implements IMessageSvc.

Definition at line 762 of file MessageSvc.cpp.

763 {
764  boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
765 
766  bool changed = true;
767  while( changed ) {
768  changed = false;
769  MessageMap::iterator first = m_messageMap.lower_bound( key );
770  MessageMap::iterator last = m_messageMap.upper_bound( key );
771  while( first != last ) {
772  const Message& message = (*first).second;
773  if ( message == msg ) {
774  m_messageMap.erase( first );
775  changed = true;
776  break;
777  }
778  }
779  }
780 }
def lock
Definition: locker.py:16
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:133
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
The Message class.
Definition: Message.h:15
boost::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
void MessageSvc::eraseStream ( )
virtual

Delete all the streams.

Implements IMessageSvc.

Definition at line 645 of file MessageSvc.cpp.

646 {
647  m_streamMap.erase( m_streamMap.begin(), m_streamMap.end() );
648 }
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
void MessageSvc::eraseStream ( int  message_type)
virtual

Delete all the streams for a given message type (severity level).

Implements IMessageSvc.

Definition at line 657 of file MessageSvc.cpp.

658 {
659  m_streamMap.erase( message_type );
660 }
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
void MessageSvc::eraseStream ( int  type,
std::ostream *  stream 
)
virtual

Delete a single stream for a given message type (severity level)

Parameters
typeSeverity level
streamPointer to a C++ stream

Implements IMessageSvc.

Definition at line 669 of file MessageSvc.cpp.

669  {
670  if ( 0 != stream ) {
671  bool changed = true;
672  while( changed ) {
673  changed = false;
674  StreamMap::iterator first = m_streamMap.lower_bound( key );
675  StreamMap::iterator last = m_streamMap.upper_bound( key );
676  while( first != last ) {
677  if ( (*first).second.second == stream ) {
678  m_streamMap.erase( first );
679  changed = true;
680  break;
681  }
682  }
683  }
684  }
685 }
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
void MessageSvc::eraseStream ( std::ostream *  stream)
virtual

Delete all occurrences of a stream.

Parameters
streamPointer to a C++ stream

Implements IMessageSvc.

Definition at line 694 of file MessageSvc.cpp.

694  {
695  if ( 0 != stream ) {
696  bool changed = true;
697  while( changed ) {
698  changed = false;
699  StreamMap::iterator first = m_streamMap.begin();
700  while( first != m_streamMap.end() ) {
701  if ( (*first).second.second == stream ) {
702  m_streamMap.erase( first );
703  changed = true;
704  break;
705  }
706  }
707  }
708  }
709 }
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
StatusCode MessageSvc::finalize ( )
virtual

Finalize Service.

Reimplemented from Service.

Definition at line 332 of file MessageSvc.cpp.

332  {
333 
334  m_suppress = false;
335 
336  {
337  std::ostringstream os;
338 
339  if (m_stats) {
340  os << "Summarizing all message counts" << endl;
341  } else {
342  os << "Listing sources of suppressed message: " << endl;
343  }
344 
345  os << "=====================================================" << endl;
346  os << " Message Source | Level | Count" << endl;
347  os << "-----------------------------+---------+-------------" << endl;
348 
349 
350  bool found(false);
351 
352  std::map<std::string,MsgAry>::const_iterator itr;
353  for (itr=m_sourceMap.begin(); itr!=m_sourceMap.end(); ++itr) {
354  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
355  if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
356  (m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
357  os << " ";
358  os.width(28);
359  os.setf(ios_base::left,ios_base::adjustfield);
360  os << itr->first;
361 
362  os << "|";
363 
364  os.width(8);
365  os.setf(ios_base::right,ios_base::adjustfield);
366  os << levelNames[ic];
367 
368  os << " |";
369 
370  os.width(9);
371  os << itr->second.msg[ic];
372 
373  os << endl;
374 
375  found = true;
376  }
377  }
378  }
379  os << "=====================================================" << endl;
380 
381  if (found || m_stats) {
382  cout << os.str();
383  }
384  }
385 
386 #ifndef NDEBUG
387  if (m_inactCount.value()) {
388 
389  std::ostringstream os;
390  os << "Listing sources of Unprotected and Unseen messages\n";
391 
392  bool found(false);
393 
394  unsigned int ml(0);
395  std::map<std::string,MsgAry>::const_iterator itr;
396  for (itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
397  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
398  if (itr->second.msg[ic] != 0) {
399  if (itr->first.length() > ml) { ml = itr->first.length(); }
400  }
401  }
402  }
403 
404  for (unsigned int i=0; i<ml+25; ++i) {
405  os << "=";
406  }
407 
408  os << endl << " ";
409  os.width(ml+2);
410  os.setf(ios_base::left,ios_base::adjustfield);
411  os << "Message Source";
412  os.width(1);
413  os << "| Level | Count" << endl;
414 
415  for (unsigned int i=0; i<ml+3; ++i) {
416  os << "-";
417  }
418  os << "+---------+-----------" << endl;
419 
420 
421  for (itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
422  for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
423  if (itr->second.msg[ic] != 0) {
424  os << " ";
425  os.width(ml+2);
426  os.setf(ios_base::left,ios_base::adjustfield);
427  os << itr->first;
428 
429  os << "|";
430 
431  os.width(8);
432  os.setf(ios_base::right,ios_base::adjustfield);
433  os << levelNames[ic];
434 
435  os << " |";
436 
437  os.width(9);
438  os << itr->second.msg[ic];
439 
440  os << endl;
441 
442  found = true;
443  }
444  }
445  }
446  for (unsigned int i=0; i<ml+25; ++i) {
447  os << "=";
448  }
449  os << endl;
450 
451  if (found) {
452  cout << os.str();
453  }
454  }
455 #endif
456 
457  return StatusCode::SUCCESS;
458 }
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:142
UnsignedIntegerProperty m_statLevel
Definition: MessageSvc.h:140
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:162
const TYPE & value() const
explicit conversion
Definition: Property.h:355
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:162
BooleanProperty m_inactCount
Definition: MessageSvc.h:163
BooleanProperty m_stats
Definition: MessageSvc.h:139
list i
Definition: ana.py:128
BooleanProperty m_suppress
Definition: MessageSvc.h:163
std::string MessageSvc::getLogColor ( int  logLevel) const
virtual

Get the color codes for various log levels.

Parameters
logLevelLogging level

Implements IMessageSvc.

Definition at line 828 of file MessageSvc.cpp.

828  {
829 // ---------------------------------------------------------------------------
830  if (logLevel < MSG::NUM_LEVELS) {
831  return m_logColorCodes[logLevel];
832  } else {
833  return "";
834  }
835 }
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:144
void MessageSvc::incrInactiveCount ( MSG::Level  level,
const std::string &  src 
)
virtual

Increment deactivated message count.

Used by MsgStream to record the sources of messages that are prepared, but not printed (because if insufficient level).

Implements IInactiveMessageCounter.

Definition at line 846 of file MessageSvc.cpp.

846  {
847 
848  ++(m_inactiveMap[source].msg[level]);
849 
850 }
std::map< std::string, MsgAry > m_inactiveMap
Definition: MessageSvc.h:162
void MessageSvc::initColors ( Property prop)
private

Definition at line 155 of file MessageSvc.cpp.

155  {
156 
157  if (m_color == true) {
158 
159  if (m_logColors[MSG::FATAL].value().size() == 0) {
160  vector<string> fatDef;
161  fatDef.push_back( "[94;101;1m" );
162  m_logColors[MSG::FATAL].set( fatDef );
163  } else {
165  }
166 
167  if (m_logColors[MSG::ERROR].value().size() == 0) {
168  vector<string> errDef;
169  errDef.push_back( "[97;101;1m" );
170  m_logColors[MSG::ERROR].set( errDef );
171  } else {
173  }
174 
175  if (m_logColors[MSG::WARNING].value().size() == 0) {
176  vector<string> warDef;
177  warDef.push_back( "[93;1m" );
178  m_logColors[MSG::WARNING].set( warDef );
179  } else {
181  }
182 
183  } else {
184 
185  // reset all color codes;
186  for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
187  vector<string> def;
188  m_logColors[ic].set( def );
189  }
190 
191  }
192 
193 }
bool set(const TYPE &value)
update the value of the property/check the verifier
Definition: Property.h:449
void setupColors(Property &prop)
Definition: MessageSvc.cpp:197
BooleanProperty m_color
Definition: MessageSvc.h:138
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:141
StatusCode MessageSvc::initialize ( )
virtual

Initialize Service.

Reimplemented from Service.

Definition at line 114 of file MessageSvc.cpp.

114  {
115  StatusCode sc;
116  sc = Service::initialize();
117  if( sc.isFailure() ) return sc;
118  // Release pointer to myself done in Service base class
119  //if( m_msgsvc.isValid() ) {
120  // m_msgsvc = 0;
121  //}
122  // Set my own properties
123  sc = setProperties();
124  if (sc.isFailure()) return sc;
125 
126 #ifdef _WIN32
127  m_color = false;
128 #endif
129 
130  m_colMap["black"] = MSG::BLACK;
131  m_colMap["red"] = MSG::RED;
132  m_colMap["green"] = MSG::GREEN;
133  m_colMap["yellow"] = MSG::YELLOW;
134  m_colMap["blue"] = MSG::BLUE;
135  m_colMap["purple"] = MSG::PURPLE;
136  m_colMap["cyan"] = MSG::CYAN;
137  m_colMap["white"] = MSG::WHITE;
138 
139  // make sure the map of logged stream names is initialized
140  setupLogStreams();
141 
142  return StatusCode::SUCCESS;
143 }
ColorMap m_colMap
Definition: MessageSvc.h:167
void setupLogStreams()
Definition: MessageSvc.cpp:853
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:371
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
BooleanProperty m_color
Definition: MessageSvc.h:138
void MessageSvc::insertMessage ( const StatusCode code,
const Message message 
)
virtual

Insert a message to be sent for a given status code into the error code repository.

Parameters
codeStatus error code
messageMessage associated

Implements IMessageSvc.

Definition at line 719 of file MessageSvc.cpp.

720 {
721  boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
722 
723  typedef MessageMap::value_type value_type;
724  m_messageMap.insert( value_type( key, msg ) );
725 }
def lock
Definition: locker.py:16
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:133
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
boost::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
void MessageSvc::insertStream ( int  type,
const std::string &  name,
std::ostream *  stream 
)
virtual

Add a new stream for a message type (severity level).

Parameters
typeSeverity level
nameStream name
streamPointer to a C++ stream

Implements IMessageSvc.

Definition at line 630 of file MessageSvc.cpp.

633 {
634  typedef StreamMap::value_type value_type;
635  m_streamMap.insert( value_type( key, NamedStream(name,stream) ) );
636 }
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
std::pair< std::string, std::ostream * > NamedStream
Definition: MessageSvc.h:33
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
int MessageSvc::messageCount ( MSG::Level  level) const
virtual

Get the number of messages issued at a particular level.

Implements IMessageSvc.

Definition at line 838 of file MessageSvc.cpp.

838  {
839 
840  return m_msgCount[level];
841 
842 }
int m_msgCount[MSG::NUM_LEVELS]
Definition: MessageSvc.h:169
int MessageSvc::outputLevel ( ) const
virtual

Retrieve the current output level threshold.

Implements IMessageSvc.

Definition at line 783 of file MessageSvc.cpp.

783  {
784 // ---------------------------------------------------------------------------
785  return m_outputLevel;
786 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:241
int MessageSvc::outputLevel ( const std::string &  source) const
virtual

Retrieve the current output level threshold for a given message source.

Parameters
sourceMessage source. Typically the alg/svc name

Implements IMessageSvc.

Definition at line 789 of file MessageSvc.cpp.

789  {
790 // ---------------------------------------------------------------------------
791  boost::recursive_mutex::scoped_lock lock(m_thresholdMapMutex);
792 
793  ThresholdMap::const_iterator it;
794 
795  it = m_thresholdMap.find( source );
796  if( it != m_thresholdMap.end() ) {
797  return (*it).second;
798  }
799  else {
800  return m_outputLevel;
801  }
802 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:241
def lock
Definition: locker.py:16
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:134
boost::recursive_mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
Definition: MessageSvc.h:194
StatusCode MessageSvc::reinitialize ( )
virtual

Reinitialize Service.

Reimplemented from Service.

Definition at line 148 of file MessageSvc.cpp.

148  {
150  return initialize();
151 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:243
virtual StatusCode initialize()
Initialize Service.
Definition: MessageSvc.cpp:114
void MessageSvc::reportMessage ( const Message message)
virtual

Report a message by sending a Message object to the message service.

Parameters
messageReference to a message object

Implements IMessageSvc.

Definition at line 556 of file MessageSvc.cpp.

556  {
557  reportMessage(msg, outputLevel(msg.getSource()));
558 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
virtual void reportMessage(const Message &message)
Report a message by sending a Message object to the message service.
Definition: MessageSvc.cpp:556
virtual int outputLevel() const
Retrieve the current output level threshold.
Definition: MessageSvc.cpp:783
void MessageSvc::reportMessage ( const Message msg,
int  outputLevel 
)
virtual

Report a message by sending a Message object to the message service.

Parameters
messageReference to a message object
outputLevelOutput level of the message source for this message

Implements IMessageSvc.

Definition at line 484 of file MessageSvc.cpp.

484  {
485  boost::recursive_mutex::scoped_lock lock(m_reportMutex);
486 
487  int key = msg.getType();
488 
489  m_msgCount[key] ++;
490 
491  const Message *cmsg = &msg;
492 
493  // processing logged streams
494  if ( !m_loggedStreams.empty() ) {
495  const LoggedStreamsMap_t::iterator iLog = m_loggedStreams.find( msg.getSource() );
496  if ( m_loggedStreams.end() != iLog ) {
497  (*iLog->second) << *cmsg << std::endl;
498  }
499  }
500 
501  if ( m_suppress.value() || m_stats.value() ) {
502 
503  // Increase the counter of 'key' type of messages for the source and
504  // get the new value.
505  const int nmsg = ++(m_sourceMap[msg.getSource()].msg[key]);
506 
507  if (m_suppress.value()) {
508 
509  if ( m_msgLimit[key] != 0 ) {
510  if (nmsg == m_msgLimit[key]) {
511  std::ostringstream txt;
512  txt << levelNames[key] << " message limit ("
513  << m_msgLimit[key].value()
514  << ") reached for "
515  << msg.getSource() + ". Suppressing further output.";
516  cmsg = new Message(msg.getSource(), MSG::WARNING, txt.str());
517  cmsg->setFormat(msg.getFormat());
518  } else if (nmsg > m_msgLimit[key]) {
519  return;
520  }
521  }
522  }
523 
524  }
525 
526  StreamMap::const_iterator first = m_streamMap.lower_bound( key );
527  if ( first != m_streamMap.end() ) {
528  StreamMap::const_iterator last = m_streamMap.upper_bound( key );
529  while( first != last ) {
530  std::ostream& stream = *( (*first).second.second );
531  stream << *cmsg << std::endl;
532  first++;
533  }
534  }
535  else if ( key >= outputLevel ) {
538  if (!m_color) {
539  (*m_defaultStream) << *cmsg << std::endl << std::flush;
540  } else {
541  (*m_defaultStream) << m_logColorCodes[key] << *cmsg << "\033[m"
542  << std::endl << std::flush;
543  }
544  }
545 
546  if (cmsg != &msg) { delete cmsg; }
547 
548 }
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:142
const std::string & getFormat() const
Get the format string.
Definition: Message.cpp:189
boost::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:187
StreamMap m_streamMap
Stream map.
Definition: MessageSvc.h:132
def lock
Definition: locker.py:16
int m_msgCount[MSG::NUM_LEVELS]
Definition: MessageSvc.h:169
void setTimeFormat(const std::string &timeFormat) const
Set the time format string.
Definition: Message.cpp:251
int getType() const
Get the message type.
Definition: Message.cpp:106
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
std::map< std::string, MsgAry > m_sourceMap
Definition: MessageSvc.h:162
virtual int outputLevel() const
Retrieve the current output level threshold.
Definition: MessageSvc.cpp:783
const TYPE & value() const
explicit conversion
Definition: Property.h:355
The Message class.
Definition: Message.h:15
std::string m_defaultFormat
Default format for the messages.
Definition: MessageSvc.h:135
LoggedStreamsMap_t m_loggedStreams
Definition: MessageSvc.h:173
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:144
const std::string & getSource() const
Get the message source.
Definition: Message.cpp:128
BooleanProperty m_color
Definition: MessageSvc.h:138
BooleanProperty m_stats
Definition: MessageSvc.h:139
BooleanProperty m_suppress
Definition: MessageSvc.h:163
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
Definition: MessageSvc.h:136
void setFormat(const std::string &msg) const
Set the format string.
Definition: Message.cpp:213
void MessageSvc::reportMessage ( const StatusCode code,
const std::string &  source = "" 
)
virtual

Report an error to the message service.

The service will use the error code number for formating a human readable message

Parameters
codeError code number
sourceMessage source. Typically the alg/svc name

Implements IMessageSvc.

Definition at line 593 of file MessageSvc.cpp.

595 {
596  boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
597 
598  MessageMap::const_iterator first = m_messageMap.lower_bound( key );
599  if ( first != m_messageMap.end() ) {
600  MessageMap::const_iterator last = m_messageMap.upper_bound( key );
601  while( first != last ) {
602  Message msg = (*first).second;
603  msg.setSource( source );
604  std::ostringstream os1;
605  os1 << "Status Code " << key.getCode() << std::ends;
606  Message stat_code1( source, msg.getType(), os1.str() );
607  reportMessage( stat_code1 );
608  reportMessage( msg );
609  first++;
610  }
611  }
612  else {
613  Message mesg = m_defaultMessage;
614  mesg.setSource( source );
615  std::ostringstream os2;
616  os2 << "Status Code " << key.getCode() << std::ends;
617  Message stat_code2( source, mesg.getType(), os2.str() );
618  reportMessage( stat_code2 );
619  reportMessage( mesg );
620  }
621 }
Message m_defaultMessage
Default Message.
Definition: MessageSvc.h:131
def lock
Definition: locker.py:16
MessageMap m_messageMap
Message map.
Definition: MessageSvc.h:133
int getType() const
Get the message type.
Definition: Message.cpp:106
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
virtual void reportMessage(const Message &message)
Report a message by sending a Message object to the message service.
Definition: MessageSvc.cpp:556
void setSource(const std::string &src)
Set the message source.
Definition: Message.cpp:139
The Message class.
Definition: Message.h:15
boost::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
Definition: MessageSvc.h:190
void MessageSvc::reportMessage ( const char *  source,
int  type,
const char *  message 
)
virtual

Report a message by specifying the source, severity level and text.

The text is passed as C like character string to avoid extra copying.

Parameters
sourceMessage source. Typically the alg/svc name
typeSeverity level
messageText message

Implements IMessageSvc.

Definition at line 566 of file MessageSvc.cpp.

568  {
569  Message msg( source, type, message);
570  reportMessage( msg );
571 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
virtual void reportMessage(const Message &message)
Report a message by sending a Message object to the message service.
Definition: MessageSvc.cpp:556
string type
Definition: gaudirun.py:126
The Message class.
Definition: Message.h:15
void MessageSvc::reportMessage ( const std::string &  source,
int  type,
const std::string &  message 
)
virtual

Report a message by specifying the source, severity level and text.

Parameters
sourceMessage source. Typically the alg/svc name
typeSeverity level
messageText message

Implements IMessageSvc.

Definition at line 579 of file MessageSvc.cpp.

581  {
582  Message msg( source, type, message);
583  reportMessage( msg );
584 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
virtual void reportMessage(const Message &message)
Report a message by sending a Message object to the message service.
Definition: MessageSvc.cpp:556
string type
Definition: gaudirun.py:126
The Message class.
Definition: Message.h:15
virtual void MessageSvc::setDefaultStream ( std::ostream *  stream)
inlinevirtual

Set the default stream.

Parameters
streamPointer to a C++ stream

Implements IMessageSvc.

Definition at line 98 of file MessageSvc.h.

98  {
99  boost::recursive_mutex::scoped_lock lock(m_reportMutex);
100  m_defaultStream = stream;
101  }
std::ostream * m_defaultStream
Pointer to the output stream.
Definition: MessageSvc.h:130
boost::recursive_mutex m_reportMutex
Mutex to synchronize multiple threads printing.
Definition: MessageSvc.h:187
def lock
Definition: locker.py:16
void MessageSvc::setOutputLevel ( int  new_level)
virtual

Set new global output level threshold.

Implements IMessageSvc.

Definition at line 805 of file MessageSvc.cpp.

805  {
806 // ---------------------------------------------------------------------------
807  m_outputLevel = new_level;
808 }
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:241
void MessageSvc::setOutputLevel ( const std::string &  source,
int  new_level 
)
virtual

Set new output level threshold for a given message source.

Parameters
sourceMessage source
new_levelSeverity level

Implements IMessageSvc.

Definition at line 811 of file MessageSvc.cpp.

811  {
812 // ---------------------------------------------------------------------------
813  boost::recursive_mutex::scoped_lock lock(m_thresholdMapMutex);
814 
815  /*
816  std::pair<ThresholdMap::iterator, bool> p;
817  p = m_thresholdMap.insert(ThresholdMap::value_type( source, level) );
818  if( p.second == false ) {
819  // Already esisting an output level for that source. Erase and enter it again
820  m_thresholdMap.erase ( p.first );
821  m_thresholdMap.insert(ThresholdMap::value_type( source, level) );
822  }
823  */
824  m_thresholdMap[source] = level;
825 }
def lock
Definition: locker.py:16
ThresholdMap m_thresholdMap
Output level threshold map.
Definition: MessageSvc.h:134
boost::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 197 of file MessageSvc.cpp.

197  {
198 
199  if (! m_color) return;
200 
201  int ic;
202  if (prop.name() == "fatalColorCode") {
203  ic = MSG::FATAL;
204  } else if (prop.name() == "errorColorCode") {
205  ic = MSG::ERROR;
206  } else if (prop.name() == "warningColorCode") {
207  ic = MSG::WARNING;
208  } else if (prop.name() == "infoColorCode") {
209  ic = MSG::INFO;
210  } else if (prop.name() == "debugColorCode") {
211  ic = MSG::DEBUG;
212  } else if (prop.name() == "verboseColorCode") {
213  ic = MSG::VERBOSE;
214  } else if (prop.name() == "alwaysColorCode") {
215  ic = MSG::ALWAYS;
216  } else {
217  cout << "ERROR: Unknown message color parameter: " << prop.name()
218  << endl;
219  return;
220  }
221 
222  string code;
223  vector<string>::const_iterator itr;
224  itr = m_logColors[ic].value().begin();
225 
226  if ( m_logColors[ic].value().size() == 1 ) {
227 
228  if (*itr == "") {
229  code = "";
230  } else if (itr->substr(0,1) == "[") {
231  code = "\033" + *itr;
232  } else {
233  code = "\033[" + colTrans(*itr, 90) + ";1m";
234  }
235 
236  } else if (m_logColors[ic].value().size() == 2) {
237  vector<string>::const_iterator itr2 = itr + 1;
238 
239  code = "\033[" + colTrans(*itr, 90) + ";"
240  + colTrans(*itr2, 100) + ";1m";
241 
242  }
243 
244  m_logColorCodes[ic] = code;
245 
246 }
std::string colTrans(std::string, int)
Definition: MessageSvc.cpp:461
const std::string & name() const
property name
Definition: Property.h:47
const TYPE & value() const
explicit conversion
Definition: Property.h:355
std::string m_logColorCodes[MSG::NUM_LEVELS]
Definition: MessageSvc.h:144
BooleanProperty m_color
Definition: MessageSvc.h:138
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
Definition: MessageSvc.h:141
void MessageSvc::setupInactCount ( Property prop)
private

Definition at line 320 of file MessageSvc.cpp.

320  {
321  if (prop.name() == "countInactive") {
322  BooleanProperty *p = dynamic_cast<BooleanProperty*>(&prop);
323  if (p)
325  }
326 }
const std::string & name() const
property name
Definition: Property.h:47
const TYPE & value() const
explicit conversion
Definition: Property.h:355
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 249 of file MessageSvc.cpp.

249  {
250  // Just report problems in the settings of the limits and unknown limit parameters
251  if (prop.name() == "alwaysLimit") {
252  IntegerProperty *p = dynamic_cast<IntegerProperty*>(&prop);
253  if (p && p->value() != 0) {
254  cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << endl;
255  p->setValue(0);
256  }
257  } else if (prop.name() == "defaultLimit") {
258  for (int i = MSG::VERBOSE; i< MSG::NUM_LEVELS; ++i) {
259  if (i != MSG::ALWAYS) {
261  }
262  }
263  } else if (prop.name() != "fatalLimit" &&
264  prop.name() != "errorLimit" &&
265  prop.name() != "warningLimit" &&
266  prop.name() == "infoLimit" &&
267  prop.name() == "debugLimit" &&
268  prop.name() == "verboseLimit") {
269  cout << "MessageSvc ERROR: Unknown message limit parameter: "
270  << prop.name() << endl;
271  return;
272  }
273 }
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
Definition: MessageSvc.h:142
const std::string & name() const
property name
Definition: Property.h:47
const TYPE & value() const
explicit conversion
Definition: Property.h:355
virtual bool setValue(const TYPE &value)
implementation of PropertyWithValue::setValue
Definition: Property.h:420
list i
Definition: ana.py:128
void MessageSvc::setupLogStreams ( )
private

Definition at line 853 of file MessageSvc.cpp.

854 {
855  // reset state
856  for ( LoggedStreamsMap_t::iterator iLog = m_loggedStreams.begin();
857  iLog != m_loggedStreams.end();
858  ++iLog ) {
859  delete iLog->second;
860  }
861  m_loggedStreams.clear();
862 
863  typedef std::map<std::string,std::string> StreamMap_t;
864  const StreamMap_t& streamMap = m_loggedStreamsName;
865  typedef StreamMap_t::const_iterator StreamMapIter;
866 
867  for ( StreamMapIter iProp = streamMap.begin(), iEnd = streamMap.end();
868  iProp != iEnd;
869  ++iProp ) {
870 
871  const std::string sourceName = iProp->first;
872  const std::string outFileName = iProp->second;
873 
874  std::set<std::string> outFileNames;
875  for ( StreamMapIter jProp = streamMap.begin();
876  jProp != iEnd;
877  ++jProp ) {
878  if ( jProp->first != iProp->first ) {
879  outFileNames.insert( jProp->second );
880  }
881  }
882 
883  tee( sourceName, outFileName, outFileNames );
884 
885  }//> loop over property entries
886 
887  return;
888 }
LoggedStreamsMap_t m_loggedStreams
Definition: MessageSvc.h:173
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
Definition: MessageSvc.cpp:891
std::map< std::string, std::string > m_loggedStreamsName
Definition: MessageSvc.h:171
void MessageSvc::setupThreshold ( Property prop)
private

Definition at line 276 of file MessageSvc.cpp.

276  {
277 
278  int ic = 0;
279  if (prop.name() == "setFatal") {
280  ic = MSG::FATAL;
281  } else if (prop.name() == "setError") {
282  ic = MSG::ERROR;
283  } else if (prop.name() == "setWarning") {
284  ic = MSG::WARNING;
285  } else if (prop.name() == "setInfo") {
286  ic = MSG::INFO;
287  } else if (prop.name() == "setDebug") {
288  ic = MSG::DEBUG;
289  } else if (prop.name() == "setVerbose") {
290  ic = MSG::VERBOSE;
291  } else if (prop.name() == "setAlways") {
292  ic = MSG::ALWAYS;
293  } else {
294  cerr << "MessageSvc ERROR: Unknown message threshold parameter: "
295  << prop.name() << endl;
296  return;
297  }
298 
299  StringArrayProperty *sap = dynamic_cast<StringArrayProperty*>( &prop);
300  if (sap == 0) {
301  std::cerr << "could not dcast " << prop.name()
302  << " to a StringArrayProperty (which it should be!)" << endl;
303  return;
304  } else {
305  std::vector<std::string>::const_iterator itr;
306  for ( itr = sap->value().begin();
307  itr != sap->value().end();
308  ++itr) {
309  setOutputLevel( *itr, ic );
310  }
311  }
312 
313 }
const std::string & name() const
property name
Definition: Property.h:47
virtual void setOutputLevel(int new_level)
Set new global output level threshold.
Definition: MessageSvc.cpp:805
const TYPE & value() const
explicit conversion
Definition: Property.h:355
void MessageSvc::tee ( const std::string &  sourceName,
const std::string &  logFileName,
const std::set< std::string > &  declaredOutFileNames 
)
private

Definition at line 891 of file MessageSvc.cpp.

894 {
895  const std::ios_base::openmode openMode = std::ios_base::out |
896  std::ios_base::trunc;
897 
898  LoggedStreamsMap_t::iterator iEnd = m_loggedStreams.end();
899  LoggedStreamsMap_t::iterator iStream = m_loggedStreams.find( sourceName );
900  if ( iStream != iEnd ) {
901  delete iStream->second;
902  iStream->second = 0;
903  m_loggedStreams.erase( iStream );
904  }
905 
906  // before creating a new ofstream, make sure there is no already existing
907  // one with the same file name...
908  iEnd = m_loggedStreams.end();
909  for ( iStream = m_loggedStreams.begin(); iStream != iEnd; ++iStream ) {
910  if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
911  m_loggedStreams[sourceName] = m_loggedStreams[iStream->first];
912  return;
913  }
914  }
915 
916  std::ofstream * out = new std::ofstream( outFileName.c_str(), openMode );
917 
918  if ( !out->good() ) {
919  out->close();
920  delete out;
921  return;
922  }
923 
924  m_loggedStreams[sourceName] = out;
925 
926  return;
927 }
LoggedStreamsMap_t m_loggedStreams
Definition: MessageSvc.h:173
virtual bool MessageSvc::useColor ( ) const
inlinevirtual

Show whether colors are used.

Implements IMessageSvc.

Definition at line 116 of file MessageSvc.h.

116 { return m_color; }
BooleanProperty m_color
Definition: MessageSvc.h:138

Member Data Documentation

ColorMap MessageSvc::m_colMap
private

Definition at line 167 of file MessageSvc.h.

BooleanProperty MessageSvc::m_color
private

Definition at line 138 of file MessageSvc.h.

std::string MessageSvc::m_defaultFormat
private

Default format for the messages.

Definition at line 135 of file MessageSvc.h.

Message MessageSvc::m_defaultMessage
private

Default Message.

Definition at line 131 of file MessageSvc.h.

std::ostream* MessageSvc::m_defaultStream
private

Pointer to the output stream.

Definition at line 130 of file MessageSvc.h.

std::string MessageSvc::m_defaultTimeFormat
private

Default format for timestamps in the messages.

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

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

Definition at line 141 of file MessageSvc.h.

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

MessageMap MessageSvc::m_messageMap
private

Message map.

Definition at line 133 of file MessageSvc.h.

boost::recursive_mutex MessageSvc::m_messageMapMutex
mutableprivate

Mutex to synchronize multiple access to m_messageMap.

Definition at line 190 of file MessageSvc.h.

int MessageSvc::m_msgCount[MSG::NUM_LEVELS]
private

Definition at line 169 of file MessageSvc.h.

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

Definition at line 142 of file MessageSvc.h.

boost::recursive_mutex MessageSvc::m_reportMutex
mutableprivate

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

BooleanProperty MessageSvc::m_stats
private

Definition at line 139 of file MessageSvc.h.

StreamMap MessageSvc::m_streamMap
private

Stream map.

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

boost::recursive_mutex MessageSvc::m_thresholdMapMutex
mutableprivate

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


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