| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

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

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:
[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 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::ostream * | defaultStream () 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::string > | getInterfaceNames () 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::string & | name () 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 Property & | getProperty (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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (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.
MsgStream & | msgStream () const
| Return an uninitialized MsgStream.
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts.
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL)
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING)
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO)
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG)
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & | msg () 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::ostream * | m_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, MsgAry > | m_sourceMap
std::map< std::string, MsgAry > | m_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

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.

: base_class( name, svcloc ) {
m_defaultStream = &std::cout;
m_outputLevel = MSG::NIL;
declareProperty( "Format", m_defaultFormat = Message::getDefaultFormat() );
declareProperty( "timeFormat", m_defaultTimeFormat = Message::getDefaultTimeFormat() );
declareProperty( "showStats", m_stats = false );
declareProperty( "statLevel", m_statLevel = 0 );
// Special properties to control output level of individual sources
declareProperty( "setVerbose", m_thresholdProp[MSG::VERBOSE] );
declareProperty( "setDebug", m_thresholdProp[MSG::DEBUG] );
declareProperty( "setInfo", m_thresholdProp[MSG::INFO] );
declareProperty( "setWarning", m_thresholdProp[MSG::WARNING] );
declareProperty( "setError", m_thresholdProp[MSG::ERROR] );
declareProperty( "setFatal", m_thresholdProp[MSG::FATAL] );
declareProperty( "setAlways", m_thresholdProp[MSG::ALWAYS] );
declareProperty( "useColors", m_color=false);
m_color.declareUpdateHandler(&MessageSvc::initColors, this);
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 );
declareProperty( "countInactive", m_inactCount = false )->declareUpdateHandler( &MessageSvc::setupInactCount, this );
#ifndef NDEBUG
// initialize the MsgStream static flag.
MsgStream::enableCountInactive(m_inactCount);
#endif
declareProperty( "loggedStreams",
m_loggedStreamsName,
"MessageStream sources we want to dump into a logfile" );
for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
m_logColors[ic].declareUpdateHandler(&MessageSvc::setupColors, this);
m_msgLimit[ic].declareUpdateHandler(&MessageSvc::setupLimits, this);
m_thresholdProp[ic].declareUpdateHandler(&MessageSvc::setupThreshold, this);
}
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
LoggedStreamsMap_t::iterator iStream = m_loggedStreams.begin();
LoggedStreamsMap_t::iterator endStream = m_loggedStreams.end();
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.

{
ColorMap::const_iterator itr = m_colMap.find(col);
int icol;
if (itr != m_colMap.end()) {
icol = offset + itr->second;
} else {
icol = offset + 8;
}
std::ostringstream os1;
os1 << icol;
return os1.str();
}

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

Definition at line 93 of file MessageSvc.h.

{
return m_defaultStream;
}

void MessageSvc::eraseMessage | ( |  | ) |
| virtual

Definition at line 734 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
m_messageMap.erase( m_messageMap.begin(), m_messageMap.end() );
}

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

Definition at line 748 of file MessageSvc.cpp.

{
boost::recursive_mutex::scoped_lock lock(m_messageMapMutex);
m_messageMap.erase( key );
}

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;
MessageMap::iterator first = m_messageMap.lower_bound( key );
MessageMap::iterator last = m_messageMap.upper_bound( key );
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.

{
m_streamMap.erase( m_streamMap.begin(), m_streamMap.end() );
}

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;
StreamMap::iterator first = m_streamMap.lower_bound( key );
StreamMap::iterator last = m_streamMap.upper_bound( key );
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;
StreamMap::iterator first = m_streamMap.begin();
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;
{
std::ostringstream os;
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);
std::map<std::string,MsgAry>::const_iterator itr;
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
if (m_inactCount.value()) {
std::ostringstream os;
os << "Listing sources of Unprotected and Unseen messages\n";
bool found(false);
unsigned int ml(0);
std::map<std::string,MsgAry>::const_iterator itr;
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
return StatusCode::SUCCESS;
}

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) {
vector<string> fatDef;
fatDef.push_back( "[94;101;1m" );
m_logColors[MSG::FATAL].set( fatDef );
} else {
MessageSvc::setupColors( m_logColors[MSG::FATAL] );
}
if (m_logColors[MSG::ERROR].value().size() == 0) {
vector<string> errDef;
errDef.push_back( "[97;101;1m" );
m_logColors[MSG::ERROR].set( errDef );
} else {
MessageSvc::setupColors( m_logColors[MSG::ERROR] );
}
if (m_logColors[MSG::WARNING].value().size() == 0) {
vector<string> warDef;
warDef.push_back( "[93;1m" );
m_logColors[MSG::WARNING].set( warDef );
} else {
MessageSvc::setupColors( m_logColors[MSG::WARNING] );
}
} else {
// reset all color codes;
for (int ic=0; ic<MSG::NUM_LEVELS; ++ic) {
vector<string> def;
m_logColors[ic].set( def );
}
}
}

StatusCode MessageSvc::initialize | ( |  | ) |
| virtual

Initialize Service.

Reimplemented from Service.

Definition at line 114 of file MessageSvc.cpp.

{
StatusCode sc;
sc = Service::initialize();
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
setupLogStreams();
return StatusCode::SUCCESS;
}

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);
ThresholdMap::const_iterator it;
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.

{
m_state = Gaudi::StateMachine::OFFLINE;
return initialize();
}

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() ) {
const LoggedStreamsMap_t::iterator iLog = m_loggedStreams.find( msg.getSource() );
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]) {
std::ostringstream txt;
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;
}
}
}
}
StreamMap::const_iterator first = m_streamMap.lower_bound( key );
if ( first != m_streamMap.end() ) {
StreamMap::const_iterator last = m_streamMap.upper_bound( key );
while( first != last ) {
std::ostream& stream = *( (*first).second.second );
stream << *cmsg << std::endl;
first++;
}
}
else if ( key >= outputLevel ) {
msg.setFormat(m_defaultFormat);
msg.setTimeFormat(m_defaultTimeFormat);
if (!m_color) {
(*m_defaultStream) << *cmsg << std::endl << std::flush;
} else {
(*m_defaultStream) << m_logColorCodes[key] << *cmsg << "\033[m"
<< std::endl << std::flush;
}
}
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);
MessageMap::const_iterator first = m_messageMap.lower_bound( key );
if ( first != m_messageMap.end() ) {
MessageMap::const_iterator last = m_messageMap.upper_bound( key );
while( first != last ) {
Message msg = (*first).second;
msg.setSource( source );
std::ostringstream os1;
os1 << "Status Code " << key.getCode() << std::ends;
Message stat_code1( source, msg.getType(), os1.str() );
reportMessage( stat_code1 );
reportMessage( msg );
first++;
}
}
else {
Message mesg = m_defaultMessage;
mesg.setSource( source );
std::ostringstream os2;
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);
reportMessage( msg );
}

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);
reportMessage( msg );
}

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

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") {
ic = MSG::WARNING;
} else if (prop.name() == "infoColorCode") {
ic = MSG::INFO;
} else if (prop.name() == "debugColorCode") {
ic = MSG::DEBUG;
} else if (prop.name() == "verboseColorCode") {
ic = MSG::VERBOSE;
} else if (prop.name() == "alwaysColorCode") {
ic = MSG::ALWAYS;
} else {
cout << "ERROR: Unknown message color parameter: " << prop.name()
<< endl;
return;
}
string code;
vector<string>::const_iterator itr;
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) {
vector<string>::const_iterator itr2 = itr + 1;
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)
MsgStream::enableCountInactive(p->value());
}
}

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) {
m_msgLimit[i] = m_msgLimit[MSG::NIL].value();
}
}
} 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
for ( LoggedStreamsMap_t::iterator iLog = m_loggedStreams.begin();
iLog != m_loggedStreams.end();
++iLog ) {
delete iLog->second;
}
m_loggedStreams.clear();
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") {
ic = MSG::WARNING;
} else if (prop.name() == "setInfo") {
ic = MSG::INFO;
} else if (prop.name() == "setDebug") {
ic = MSG::DEBUG;
} else if (prop.name() == "setVerbose") {
ic = MSG::VERBOSE;
} else if (prop.name() == "setAlways") {
ic = MSG::ALWAYS;
} 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 {
std::vector<std::string>::const_iterator itr;
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.

{
const std::ios_base::openmode openMode = std::ios_base::out |
std::ios_base::trunc;
LoggedStreamsMap_t::iterator iEnd = m_loggedStreams.end();
LoggedStreamsMap_t::iterator iStream = m_loggedStreams.find( sourceName );
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
| inline virtual

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
| mutable private

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

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/MessageSvc/MessageSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/MessageSvc/MessageSvc.cpp