Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MessageSvc Class Reference

#include <MessageSvc.h>

Inheritance diagram for MessageSvc:
Inheritance graph
[legend]
Collaboration diagram for MessageSvc:
Collaboration graph
[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 extends2< Service, IMessageSvc, IInactiveMessageCounter >
typedef extends2 base_class
 Typedef to this class.
 
typedef extend_interfaces2
< IMessageSvc,
IInactiveMessageCounter
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- 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.
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Public Types inherited from extend_interfaces3< I1, I2, I3 >
typedef mpl::fold< typename
I1::iid::iids::type, typename
mpl::fold< typename
I2::iid::iids::type, typename
I3::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.
 
- Public Types inherited from extend_interfaces2< I1, I2 >
typedef mpl::fold< typename
I1::iid::iids::type, typename
I2::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type 
ext_iids
 MPL set of interfaces extended by this one.
 

Public Member Functions

 MessageSvc (const std::string &name, ISvcLocator *svcloc)
 
virtual ~MessageSvc ()
 
virtual StatusCode reinitialize ()
 Reinitialize Service.
 
virtual StatusCode initialize ()
 Initialize Service.
 
virtual StatusCode finalize ()
 Finalize Service.
 
virtual void reportMessage (const Message &message)
 
virtual void reportMessage (const Message &msg, int outputLevel)
 
virtual void reportMessage (const StatusCode &code, const std::string &source="")
 
virtual void reportMessage (const char *source, int type, const char *message)
 
virtual void reportMessage (const std::string &source, int type, const std::string &message)
 
virtual void insertMessage (const StatusCode &code, const Message &message)
 
virtual void eraseMessage ()
 
virtual void eraseMessage (const StatusCode &code)
 
virtual void eraseMessage (const StatusCode &code, const Message &message)
 
virtual void insertStream (int message_type, const std::string &name, std::ostream *stream)
 
virtual void eraseStream ()
 
virtual void eraseStream (int message_type)
 
virtual void eraseStream (int message_type, std::ostream *stream)
 
virtual void eraseStream (std::ostream *stream)
 
virtual std::ostreamdefaultStream () const
 
virtual void setDefaultStream (std::ostream *stream)
 
virtual int outputLevel () const
 
virtual int outputLevel (const std::string &source) const
 
virtual void setOutputLevel (int new_level)
 
virtual void setOutputLevel (const std::string &source, int new_level)
 
virtual bool useColor () const
 
virtual std::string getLogColor (int logLevel) const
 
virtual int messageCount (MSG::Level logLevel) const
 
virtual void incrInactiveCount (MSG::Level level, const std::string &src)
 
- Public Member Functions inherited from extends2< Service, IMessageSvc, IInactiveMessageCounter >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends2 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
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.
 
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.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- 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.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual ~extend_interfaces2 ()
 Virtual destructor.
 

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::ostreamm_defaultStream
 Pointer to the output stream.
 
Message m_defaultMessage
 Default Message.
 
StreamMap m_streamMap
 Stream map.
 
MessageMap m_messageMap
 Message map.
 
ThresholdMap m_thresholdMap
 Output level threshold map.
 
std::string m_defaultFormat
 Default format for the messages.
 
std::string m_defaultTimeFormat
 Default format for timestamps in the messages.
 
StringArrayProperty m_thresholdProp [MSG::NUM_LEVELS]
 Properties controlling.
 
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.
 
boost::recursive_mutex m_messageMapMutex
 Mutex to synchronize multiple access to m_messageMap.
 
boost::recursive_mutex m_thresholdMapMutex
 Mutex to synchronize multiple access to m_thresholdMap (.
 

Additional Inherited Members

- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Definition at line 31 of file MessageSvc.h.

Member Typedef Documentation

Definition at line 166 of file MessageSvc.h.

Definition at line 172 of file MessageSvc.h.

Definition at line 35 of file MessageSvc.h.

Definition at line 33 of file MessageSvc.h.

Definition at line 34 of file MessageSvc.h.

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.

: base_class( name, svcloc ) {
declareProperty( "showStats", m_stats = false );
declareProperty( "statLevel", m_statLevel = 0 );
// Special properties to control output level of individual sources
declareProperty( "useColors", m_color=false);
declareProperty( "fatalColorCode", m_logColors[MSG::FATAL] );
declareProperty( "errorColorCode", m_logColors[MSG::ERROR] );
declareProperty( "warningColorCode", m_logColors[MSG::WARNING] );
declareProperty( "infoColorCode", m_logColors[MSG::INFO] );
declareProperty( "debugColorCode", m_logColors[MSG::DEBUG] );
declareProperty( "verboseColorCode", m_logColors[MSG::VERBOSE] );
declareProperty( "alwaysColorCode", m_logColors[MSG::ALWAYS] );
const int defaultLimit = 500;
declareProperty( "fatalLimit", m_msgLimit[MSG::FATAL] = defaultLimit );
declareProperty( "errorLimit", m_msgLimit[MSG::ERROR] = defaultLimit );
declareProperty( "warningLimit", m_msgLimit[MSG::WARNING] = defaultLimit );
declareProperty( "infoLimit", m_msgLimit[MSG::INFO] = defaultLimit );
declareProperty( "debugLimit", m_msgLimit[MSG::DEBUG] = defaultLimit );
declareProperty( "verboseLimit", m_msgLimit[MSG::VERBOSE] = defaultLimit );
declareProperty( "alwaysLimit", m_msgLimit[MSG::ALWAYS] = 0 );
declareProperty( "defaultLimit", m_msgLimit[MSG::NIL] = defaultLimit );
declareProperty( "enableSuppression", m_suppress = false );
#ifndef NDEBUG
// initialize the MsgStream static flag.
#endif
declareProperty( "loggedStreams",
"MessageStream sources we want to dump into a logfile" );
for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
}
levelNames[0] = "NIL";
levelNames[1] = "VERBOSE";
levelNames[2] = "DEBUG";
levelNames[3] = "INFO";
levelNames[4] = "WARNING";
levelNames[5] = "ERROR";
levelNames[6] = "FATAL";
levelNames[7] = "ALWAYS";
for (int i=0; i<MSG::NUM_LEVELS; ++i) {
m_msgCount[i] = 0;
}
}
MessageSvc::~MessageSvc ( )
virtual

Definition at line 100 of file MessageSvc.cpp.

{
// closing log-files, if any
for ( ; iStream != endStream; ++iStream ) {
delete iStream->second;
iStream->second = 0;
}
}

Member Function Documentation

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

Definition at line 461 of file MessageSvc.cpp.

{
int icol;
if (itr != m_colMap.end()) {
icol = offset + itr->second;
} else {
icol = offset + 8;
}
os1 << icol;
return os1.str();
}
virtual std::ostream* MessageSvc::defaultStream ( ) const
inlinevirtual

Definition at line 93 of file MessageSvc.h.

{
}
void MessageSvc::eraseMessage ( )
virtual

Definition at line 734 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
}
void MessageSvc::eraseMessage ( const StatusCode code)
virtual

Definition at line 748 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
}
void MessageSvc::eraseMessage ( const StatusCode code,
const Message message 
)
virtual

Definition at line 762 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
bool changed = true;
while( changed ) {
changed = false;
while( first != last ) {
const Message& message = (*first).second;
if ( message == msg ) {
m_messageMap.erase( first );
changed = true;
break;
}
}
}
}
void MessageSvc::eraseStream ( )
virtual

Definition at line 645 of file MessageSvc.cpp.

void MessageSvc::eraseStream ( int  message_type)
virtual

Definition at line 657 of file MessageSvc.cpp.

{
m_streamMap.erase( message_type );
}
void MessageSvc::eraseStream ( int  message_type,
std::ostream stream 
)
virtual

Definition at line 669 of file MessageSvc.cpp.

{
if ( 0 != stream ) {
bool changed = true;
while( changed ) {
changed = false;
while( first != last ) {
if ( (*first).second.second == stream ) {
m_streamMap.erase( first );
changed = true;
break;
}
}
}
}
}
void MessageSvc::eraseStream ( std::ostream stream)
virtual

Definition at line 694 of file MessageSvc.cpp.

{
if ( 0 != stream ) {
bool changed = true;
while( changed ) {
changed = false;
while( first != m_streamMap.end() ) {
if ( (*first).second.second == stream ) {
m_streamMap.erase( first );
changed = true;
break;
}
}
}
}
}
StatusCode MessageSvc::finalize ( )
virtual

Finalize Service.

Reimplemented from Service.

Definition at line 332 of file MessageSvc.cpp.

{
m_suppress = false;
{
if (m_stats) {
os << "Summarizing all message counts" << endl;
} else {
os << "Listing sources of suppressed message: " << endl;
}
os << "=====================================================" << endl;
os << " Message Source | Level | Count" << endl;
os << "-----------------------------+---------+-------------" << endl;
bool found(false);
for (itr=m_sourceMap.begin(); itr!=m_sourceMap.end(); ++itr) {
for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
if ( (itr->second.msg[ic] >= m_msgLimit[ic] && m_msgLimit[ic] != 0 ) ||
(m_stats && itr->second.msg[ic] > 0 && ic >= m_statLevel.value()) ) {
os << " ";
os.width(28);
os.setf(ios_base::left,ios_base::adjustfield);
os << itr->first;
os << "|";
os.width(8);
os.setf(ios_base::right,ios_base::adjustfield);
os << levelNames[ic];
os << " |";
os.width(9);
os << itr->second.msg[ic];
os << endl;
found = true;
}
}
}
os << "=====================================================" << endl;
if (found || m_stats) {
cout << os.str();
}
}
#ifndef NDEBUG
os << "Listing sources of Unprotected and Unseen messages\n";
bool found(false);
unsigned int ml(0);
for (itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
if (itr->second.msg[ic] != 0) {
if (itr->first.length() > ml) { ml = itr->first.length(); }
}
}
}
for (unsigned int i=0; i<ml+25; ++i) {
os << "=";
}
os << endl << " ";
os.width(ml+2);
os.setf(ios_base::left,ios_base::adjustfield);
os << "Message Source";
os.width(1);
os << "| Level | Count" << endl;
for (unsigned int i=0; i<ml+3; ++i) {
os << "-";
}
os << "+---------+-----------" << endl;
for (itr=m_inactiveMap.begin(); itr!=m_inactiveMap.end(); ++itr) {
for (unsigned int ic = 0; ic < MSG::NUM_LEVELS; ++ic) {
if (itr->second.msg[ic] != 0) {
os << " ";
os.width(ml+2);
os.setf(ios_base::left,ios_base::adjustfield);
os << itr->first;
os << "|";
os.width(8);
os.setf(ios_base::right,ios_base::adjustfield);
os << levelNames[ic];
os << " |";
os.width(9);
os << itr->second.msg[ic];
os << endl;
found = true;
}
}
}
for (unsigned int i=0; i<ml+25; ++i) {
os << "=";
}
os << endl;
if (found) {
cout << os.str();
}
}
#endif
}
std::string MessageSvc::getLogColor ( int  logLevel) const
virtual

Definition at line 828 of file MessageSvc.cpp.

{
// ---------------------------------------------------------------------------
if (logLevel < MSG::NUM_LEVELS) {
return m_logColorCodes[logLevel];
} else {
return "";
}
}
void MessageSvc::incrInactiveCount ( MSG::Level  level,
const std::string src 
)
virtual

Definition at line 846 of file MessageSvc.cpp.

{
++(m_inactiveMap[source].msg[level]);
}
void MessageSvc::initColors ( Property prop)
private

Definition at line 155 of file MessageSvc.cpp.

{
if (m_color == true) {
if (m_logColors[MSG::FATAL].value().size() == 0) {
fatDef.push_back( "[94;101;1m" );
} else {
}
if (m_logColors[MSG::ERROR].value().size() == 0) {
errDef.push_back( "[97;101;1m" );
} else {
}
if (m_logColors[MSG::WARNING].value().size() == 0) {
warDef.push_back( "[93;1m" );
} else {
}
} else {
// reset all color codes;
for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
m_logColors[ic].set( def );
}
}
}
StatusCode MessageSvc::initialize ( )
virtual

Initialize Service.

Reimplemented from Service.

Definition at line 114 of file MessageSvc.cpp.

{
if( sc.isFailure() ) return sc;
// Release pointer to myself done in Service base class
//if( m_msgsvc.isValid() ) {
// m_msgsvc = 0;
//}
// Set my own properties
sc = setProperties();
if (sc.isFailure()) return sc;
#ifdef _WIN32
m_color = false;
#endif
m_colMap["black"] = MSG::BLACK;
m_colMap["red"] = MSG::RED;
m_colMap["green"] = MSG::GREEN;
m_colMap["yellow"] = MSG::YELLOW;
m_colMap["blue"] = MSG::BLUE;
m_colMap["purple"] = MSG::PURPLE;
m_colMap["cyan"] = MSG::CYAN;
m_colMap["white"] = MSG::WHITE;
// make sure the map of logged stream names is initialized
}
void MessageSvc::insertMessage ( const StatusCode code,
const Message message 
)
virtual

Definition at line 719 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
typedef MessageMap::value_type value_type;
m_messageMap.insert( value_type( key, msg ) );
}
void MessageSvc::insertStream ( int  message_type,
const std::string name,
std::ostream stream 
)
virtual

Definition at line 630 of file MessageSvc.cpp.

{
typedef StreamMap::value_type value_type;
m_streamMap.insert( value_type( key, NamedStream(name,stream) ) );
}
int MessageSvc::messageCount ( MSG::Level  logLevel) const
virtual

Definition at line 838 of file MessageSvc.cpp.

{
return m_msgCount[level];
}
int MessageSvc::outputLevel ( ) const
virtual

Definition at line 783 of file MessageSvc.cpp.

{
// ---------------------------------------------------------------------------
return m_outputLevel;
}
int MessageSvc::outputLevel ( const std::string source) const
virtual

Definition at line 789 of file MessageSvc.cpp.

{
// ---------------------------------------------------------------------------
boost::recursive_mutex::scoped_lock lock(m_thresholdMapMutex);
it = m_thresholdMap.find( source );
if( it != m_thresholdMap.end() ) {
return (*it).second;
}
else {
return m_outputLevel;
}
}
StatusCode MessageSvc::reinitialize ( )
virtual

Reinitialize Service.

Reimplemented from Service.

Definition at line 148 of file MessageSvc.cpp.

void MessageSvc::reportMessage ( const Message message)
virtual

Definition at line 556 of file MessageSvc.cpp.

{
reportMessage(msg, outputLevel(msg.getSource()));
}
void MessageSvc::reportMessage ( const Message msg,
int  outputLevel 
)
virtual

Definition at line 484 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_reportMutex);
int key = msg.getType();
m_msgCount[key] ++;
const Message *cmsg = &msg;
// processing logged streams
if ( !m_loggedStreams.empty() ) {
if ( m_loggedStreams.end() != iLog ) {
(*iLog->second) << *cmsg << std::endl;
}
}
if ( m_suppress.value() || m_stats.value() ) {
// Increase the counter of 'key' type of messages for the source and
// get the new value.
const int nmsg = ++(m_sourceMap[msg.getSource()].msg[key]);
if (m_suppress.value()) {
if ( m_msgLimit[key] != 0 ) {
if (nmsg == m_msgLimit[key]) {
txt << levelNames[key] << " message limit ("
<< m_msgLimit[key].value()
<< ") reached for "
<< msg.getSource() + ". Suppressing further output.";
cmsg = new Message(msg.getSource(), MSG::WARNING, txt.str());
cmsg->setFormat(msg.getFormat());
} else if (nmsg > m_msgLimit[key]) {
return;
}
}
}
}
if ( first != m_streamMap.end() ) {
while( first != last ) {
std::ostream& stream = *( (*first).second.second );
stream << *cmsg << std::endl;
first++;
}
}
else if ( key >= outputLevel ) {
if (!m_color) {
(*m_defaultStream) << *cmsg << std::endl << std::flush;
} else {
(*m_defaultStream) << m_logColorCodes[key] << *cmsg << "\033[m"
}
}
if (cmsg != &msg) { delete cmsg; }
}
void MessageSvc::reportMessage ( const StatusCode code,
const std::string source = "" 
)
virtual

Definition at line 593 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
if ( first != m_messageMap.end() ) {
while( first != last ) {
Message msg = (*first).second;
msg.setSource( source );
os1 << "Status Code " << key.getCode() << std::ends;
Message stat_code1( source, msg.getType(), os1.str() );
reportMessage( stat_code1 );
reportMessage( msg );
first++;
}
}
else {
mesg.setSource( source );
os2 << "Status Code " << key.getCode() << std::ends;
Message stat_code2( source, mesg.getType(), os2.str() );
reportMessage( stat_code2 );
reportMessage( mesg );
}
}
void MessageSvc::reportMessage ( const char *  source,
int  type,
const char *  message 
)
virtual

Definition at line 566 of file MessageSvc.cpp.

{
Message msg( source, type, message);
}
void MessageSvc::reportMessage ( const std::string source,
int  type,
const std::string message 
)
virtual

Definition at line 579 of file MessageSvc.cpp.

{
Message msg( source, type, message);
}
virtual void MessageSvc::setDefaultStream ( std::ostream stream)
inlinevirtual

Definition at line 98 of file MessageSvc.h.

{
boost::recursive_mutex::scoped_lock lock(m_reportMutex);
m_defaultStream = stream;
}
void MessageSvc::setOutputLevel ( int  new_level)
virtual

Definition at line 805 of file MessageSvc.cpp.

{
// ---------------------------------------------------------------------------
m_outputLevel = new_level;
}
void MessageSvc::setOutputLevel ( const std::string source,
int  new_level 
)
virtual

Definition at line 811 of file MessageSvc.cpp.

{
// ---------------------------------------------------------------------------
boost::recursive_mutex::scoped_lock lock(m_thresholdMapMutex);
/*
std::pair<ThresholdMap::iterator, bool> p;
p = m_thresholdMap.insert(ThresholdMap::value_type( source, level) );
if( p.second == false ) {
// Already esisting an output level for that source. Erase and enter it again
m_thresholdMap.erase ( p.first );
m_thresholdMap.insert(ThresholdMap::value_type( source, level) );
}
*/
m_thresholdMap[source] = level;
}
void MessageSvc::setupColors ( Property prop)
private

Definition at line 197 of file MessageSvc.cpp.

{
if (! m_color) return;
int ic;
if (prop.name() == "fatalColorCode") {
ic = MSG::FATAL;
} else if (prop.name() == "errorColorCode") {
ic = MSG::ERROR;
} else if (prop.name() == "warningColorCode") {
} else if (prop.name() == "infoColorCode") {
ic = MSG::INFO;
} else if (prop.name() == "debugColorCode") {
ic = MSG::DEBUG;
} else if (prop.name() == "verboseColorCode") {
} else if (prop.name() == "alwaysColorCode") {
} else {
cout << "ERROR: Unknown message color parameter: " << prop.name()
<< endl;
return;
}
string code;
itr = m_logColors[ic].value().begin();
if ( m_logColors[ic].value().size() == 1 ) {
if (*itr == "") {
code = "";
} else if (itr->substr(0,1) == "[") {
code = "\033" + *itr;
} else {
code = "\033[" + colTrans(*itr, 90) + ";1m";
}
} else if (m_logColors[ic].value().size() == 2) {
code = "\033[" + colTrans(*itr, 90) + ";"
+ colTrans(*itr2, 100) + ";1m";
}
m_logColorCodes[ic] = code;
}
void MessageSvc::setupInactCount ( Property prop)
private

Definition at line 320 of file MessageSvc.cpp.

{
if (prop.name() == "countInactive") {
BooleanProperty *p = dynamic_cast<BooleanProperty*>(&prop);
if (p)
}
}
void MessageSvc::setupLimits ( Property prop)
private

Definition at line 249 of file MessageSvc.cpp.

{
// Just report problems in the settings of the limits and unknown limit parameters
if (prop.name() == "alwaysLimit") {
IntegerProperty *p = dynamic_cast<IntegerProperty*>(&prop);
if (p && p->value() != 0) {
cout << "MessageSvc ERROR: cannot suppress ALWAYS messages" << endl;
p->setValue(0);
}
} else if (prop.name() == "defaultLimit") {
for (int i = MSG::VERBOSE; i< MSG::NUM_LEVELS; ++i) {
if (i != MSG::ALWAYS) {
}
}
} else if (prop.name() != "fatalLimit" &&
prop.name() != "errorLimit" &&
prop.name() != "warningLimit" &&
prop.name() == "infoLimit" &&
prop.name() == "debugLimit" &&
prop.name() == "verboseLimit") {
cout << "MessageSvc ERROR: Unknown message limit parameter: "
<< prop.name() << endl;
return;
}
}
void MessageSvc::setupLogStreams ( )
private

Definition at line 853 of file MessageSvc.cpp.

{
// reset state
iLog != m_loggedStreams.end();
++iLog ) {
delete iLog->second;
}
typedef std::map<std::string,std::string> StreamMap_t;
const StreamMap_t& streamMap = m_loggedStreamsName;
typedef StreamMap_t::const_iterator StreamMapIter;
for ( StreamMapIter iProp = streamMap.begin(), iEnd = streamMap.end();
iProp != iEnd;
++iProp ) {
const std::string sourceName = iProp->first;
const std::string outFileName = iProp->second;
std::set<std::string> outFileNames;
for ( StreamMapIter jProp = streamMap.begin();
jProp != iEnd;
++jProp ) {
if ( jProp->first != iProp->first ) {
outFileNames.insert( jProp->second );
}
}
tee( sourceName, outFileName, outFileNames );
}//> loop over property entries
return;
}
void MessageSvc::setupThreshold ( Property prop)
private

Definition at line 276 of file MessageSvc.cpp.

{
int ic = 0;
if (prop.name() == "setFatal") {
ic = MSG::FATAL;
} else if (prop.name() == "setError") {
ic = MSG::ERROR;
} else if (prop.name() == "setWarning") {
} else if (prop.name() == "setInfo") {
ic = MSG::INFO;
} else if (prop.name() == "setDebug") {
ic = MSG::DEBUG;
} else if (prop.name() == "setVerbose") {
} else if (prop.name() == "setAlways") {
} else {
cerr << "MessageSvc ERROR: Unknown message threshold parameter: "
<< prop.name() << endl;
return;
}
StringArrayProperty *sap = dynamic_cast<StringArrayProperty*>( &prop);
if (sap == 0) {
std::cerr << "could not dcast " << prop.name()
<< " to a StringArrayProperty (which it should be!)" << endl;
return;
} else {
for ( itr = sap->value().begin();
itr != sap->value().end();
++itr) {
setOutputLevel( *itr, ic );
}
}
}
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.

{
if ( iStream != iEnd ) {
delete iStream->second;
iStream->second = 0;
m_loggedStreams.erase( iStream );
}
// before creating a new ofstream, make sure there is no already existing
// one with the same file name...
iEnd = m_loggedStreams.end();
for ( iStream = m_loggedStreams.begin(); iStream != iEnd; ++iStream ) {
if ( outFileNames.find( outFileName ) != outFileNames.end() ) {
m_loggedStreams[sourceName] = m_loggedStreams[iStream->first];
return;
}
}
std::ofstream * out = new std::ofstream( outFileName.c_str(), openMode );
if ( !out->good() ) {
out->close();
delete out;
return;
}
m_loggedStreams[sourceName] = out;
return;
}
virtual bool MessageSvc::useColor ( ) const
inlinevirtual

Definition at line 116 of file MessageSvc.h.

{ return m_color; }

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:

Generated at Mon Feb 17 2014 14:38:07 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004