|
Gaudi Framework, version v22r1 |
| Home | Generated: Mon Feb 28 2011 |
#include <MessageSvc.h>


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 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) |
| Report a message by sending a Message object to the message service. | |
| virtual void | reportMessage (const Message &msg, int outputLevel) |
| Report a message by sending a Message object to the message service. | |
| virtual void | reportMessage (const StatusCode &code, const std::string &source="") |
| Report an error to the message service. | |
| virtual void | reportMessage (const char *source, int type, const char *message) |
| Report a message by specifying the source, severity level and text. | |
| virtual void | reportMessage (const std::string &source, int type, const std::string &message) |
| Report a message by specifying the source, severity level and text. | |
| 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. | |
| virtual void | eraseMessage () |
| Erase all messages associated to all status codes. | |
| virtual void | eraseMessage (const StatusCode &code) |
| Erase message associated to a given status code. | |
| virtual void | eraseMessage (const StatusCode &code, const Message &message) |
| Erase a given message associated to a given status code. | |
| virtual void | insertStream (int message_type, const std::string &name, std::ostream *stream) |
| Add a new stream for a message type (severity level). | |
| virtual void | eraseStream () |
| Delete all the streams. | |
| virtual void | eraseStream (int message_type) |
| Delete all the streams for a given message type (severity level). | |
| virtual void | eraseStream (int message_type, std::ostream *stream) |
| Delete a single stream for a given message type (severity level) | |
| virtual void | eraseStream (std::ostream *stream) |
| Delete all occurrences of a stream. | |
| virtual std::ostream * | defaultStream () const |
| Get the default stream. | |
| virtual void | setDefaultStream (std::ostream *stream) |
| Set the default stream. | |
| virtual int | outputLevel () const |
get the Service's output level | |
| virtual int | outputLevel (const std::string &source) const |
| Retrieve the current output level threshold for a given message source. | |
| virtual void | setOutputLevel (int new_level) |
| Set new global output level threshold. | |
| virtual void | setOutputLevel (const std::string &source, int new_level) |
| Set new output level threshold for a given message source. | |
| virtual bool | useColor () const |
| Show whether colors are used. | |
| virtual std::string | getLogColor (int logLevel) const |
| Get the color codes for various log levels. | |
| virtual int | messageCount (MSG::Level logLevel) const |
| Get the number of messages issued at a particular level. | |
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 | 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 controling. | |
| 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 |
| BooleanProperty | m_suppress |
| 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 (. | |
Definition at line 32 of file MessageSvc.h.
typedef std::map<std::string, MSG::Color> MessageSvc::ColorMap [private] |
Definition at line 162 of file MessageSvc.h.
typedef std::map<std::string, std::ostream*> MessageSvc::LoggedStreamsMap_t [private] |
Definition at line 168 of file MessageSvc.h.
| typedef std::multimap< StatusCode, Message > MessageSvc::MessageMap |
Definition at line 36 of file MessageSvc.h.
| typedef std::pair< std::string, std::ostream* > MessageSvc::NamedStream |
Definition at line 34 of file MessageSvc.h.
| typedef std::multimap< int, NamedStream > MessageSvc::StreamMap |
Definition at line 35 of file MessageSvc.h.
| typedef std::map< std::string, int > MessageSvc::ThresholdMap |
Definition at line 37 of file MessageSvc.h.
| MessageSvc::MessageSvc | ( | const std::string & | name, |
| ISvcLocator * | svcloc | ||
| ) |
Definition at line 28 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( "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 97 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;
}
}
| std::string MessageSvc::colTrans | ( | std::string | col, |
| int | offset | ||
| ) | [private] |
Definition at line 369 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] |
Get the default stream.
Implements IMessageSvc.
Definition at line 94 of file MessageSvc.h.
{
return m_defaultStream;
}
| void MessageSvc::eraseMessage | ( | ) | [virtual] |
Erase all messages associated to all status codes.
Implements IMessageSvc.
Definition at line 642 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] |
Erase message associated to a given status code.
Implements IMessageSvc.
Definition at line 656 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] |
Erase a given message associated to a given status code.
| code | Status error code |
| message | Message associated |
Implements IMessageSvc.
Definition at line 670 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 | ( | std::ostream * | stream ) | [virtual] |
Delete all occurrences of a stream.
| stream | Pointer to a C++ stream |
Implements IMessageSvc.
Definition at line 602 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;
}
}
}
}
}
| void MessageSvc::eraseStream | ( | int | type, |
| std::ostream * | stream | ||
| ) | [virtual] |
Delete a single stream for a given message type (severity level)
| type | Severity level |
| stream | Pointer to a C++ stream |
Implements IMessageSvc.
Definition at line 577 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 | ( | ) | [virtual] |
Delete all the streams.
Implements IMessageSvc.
Definition at line 553 of file MessageSvc.cpp.
{
m_streamMap.erase( m_streamMap.begin(), m_streamMap.end() );
}
| void MessageSvc::eraseStream | ( | int | message_type ) | [virtual] |
Delete all the streams for a given message type (severity level).
Implements IMessageSvc.
Definition at line 565 of file MessageSvc.cpp.
{
m_streamMap.erase( message_type );
}
| StatusCode MessageSvc::finalize | ( | ) | [virtual] |
Finalize Service.
Reimplemented from Service.
Definition at line 313 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();
}
return StatusCode::SUCCESS;
}
| std::string MessageSvc::getLogColor | ( | int | logLevel ) | const [virtual] |
Get the color codes for various log levels.
| logLevel | Logging level |
Implements IMessageSvc.
Definition at line 736 of file MessageSvc.cpp.
{
// ---------------------------------------------------------------------------
if (logLevel < MSG::NUM_LEVELS) {
return m_logColorCodes[logLevel];
} else {
return "";
}
}
| void MessageSvc::initColors | ( | Property & | prop ) | [private] |
Definition at line 152 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 111 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] |
Insert a message to be sent for a given status code into the error code repository.
| code | Status error code |
| message | Message associated |
Implements IMessageSvc.
Definition at line 627 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 | type, |
| const std::string & | name, | ||
| std::ostream * | stream | ||
| ) | [virtual] |
Add a new stream for a message type (severity level).
| type | Severity level |
| name | Stream name |
| stream | Pointer to a C++ stream |
Implements IMessageSvc.
Definition at line 538 of file MessageSvc.cpp.
{
typedef StreamMap::value_type value_type;
m_streamMap.insert( value_type( key, NamedStream(name,stream) ) );
}
| int MessageSvc::messageCount | ( | MSG::Level | level ) | const [virtual] |
Get the number of messages issued at a particular level.
Implements IMessageSvc.
Definition at line 746 of file MessageSvc.cpp.
{
return m_msgCount[level];
}
| int MessageSvc::outputLevel | ( | ) | const [virtual] |
get the Service's output level
Reimplemented from Service.
Definition at line 691 of file MessageSvc.cpp.
{
// ---------------------------------------------------------------------------
return m_outputLevel;
}
| int MessageSvc::outputLevel | ( | const std::string & | source ) | const [virtual] |
Retrieve the current output level threshold for a given message source.
| source | Message source. Typically the alg/svc name |
Implements IMessageSvc.
Definition at line 697 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 145 of file MessageSvc.cpp.
{
m_state = Gaudi::StateMachine::OFFLINE;
return initialize();
}
| 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.
| source | Message source. Typically the alg/svc name |
| type | Severity level |
| message | Text message |
Implements IMessageSvc.
Definition at line 487 of file MessageSvc.cpp.
{
Message msg( source, type, message);
reportMessage( msg );
}
| void MessageSvc::reportMessage | ( | const Message & | message ) | [virtual] |
Report a message by sending a Message object to the message service.
| message | Reference to a message object |
Implements IMessageSvc.
Definition at line 464 of file MessageSvc.cpp.
{
reportMessage(msg, outputLevel(msg.getSource()));
}
| 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
| code | Error code number |
| source | Message source. Typically the alg/svc name |
Implements IMessageSvc.
Definition at line 501 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] |
Report a message by specifying the source, severity level and text.
The text is passed as C like character string to avoid extra copying.
| source | Message source. Typically the alg/svc name |
| type | Severity level |
| message | Text message |
Implements IMessageSvc.
Definition at line 474 of file MessageSvc.cpp.
{
Message msg( source, type, message);
reportMessage( msg );
}
| void MessageSvc::reportMessage | ( | const Message & | msg, |
| int | outputLevel | ||
| ) | [virtual] |
Report a message by sending a Message object to the message service.
| message | Reference to a message object |
| outputLevel | Output level of the message source for this message |
Implements IMessageSvc.
Definition at line 392 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]) {
char lim[16];
std::string str = levelNames[key] + " message limit (";
str += ::_itoa(m_msgLimit[key].value(),lim,10);
str += ") reached for ";
str += msg.getSource() + ". Suppressing further output.";
cmsg = new Message(msg.getSource(),MSG::WARNING,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; }
}
| virtual void MessageSvc::setDefaultStream | ( | std::ostream * | stream ) | [inline, virtual] |
Set the default stream.
| stream | Pointer to a C++ stream |
Implements IMessageSvc.
Definition at line 99 of file MessageSvc.h.
{
boost::recursive_mutex::scoped_lock lock(m_reportMutex);
m_defaultStream = stream;
}
| void MessageSvc::setOutputLevel | ( | int | new_level ) | [virtual] |
Set new global output level threshold.
Implements IMessageSvc.
Definition at line 713 of file MessageSvc.cpp.
{
// ---------------------------------------------------------------------------
m_outputLevel = new_level;
}
| void MessageSvc::setOutputLevel | ( | const std::string & | source, |
| int | new_level | ||
| ) | [virtual] |
Set new output level threshold for a given message source.
| source | Message source |
| new_level | Severity level |
Implements IMessageSvc.
Definition at line 719 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 194 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::setupLimits | ( | Property & | prop ) | [private] |
Definition at line 246 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 753 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 273 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 791 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] |
Show whether colors are used.
Implements IMessageSvc.
Definition at line 117 of file MessageSvc.h.
{ return m_color; }
ColorMap MessageSvc::m_colMap [private] |
Definition at line 163 of file MessageSvc.h.
BooleanProperty MessageSvc::m_color [private] |
Definition at line 134 of file MessageSvc.h.
std::string MessageSvc::m_defaultFormat [private] |
Default format for the messages.
Definition at line 131 of file MessageSvc.h.
Message MessageSvc::m_defaultMessage [private] |
Default Message.
Definition at line 127 of file MessageSvc.h.
std::ostream* MessageSvc::m_defaultStream [private] |
Pointer to the output stream.
Definition at line 126 of file MessageSvc.h.
std::string MessageSvc::m_defaultTimeFormat [private] |
Default format for timestamps in the messages.
Definition at line 132 of file MessageSvc.h.
std::string MessageSvc::m_logColorCodes[MSG::NUM_LEVELS] [private] |
Definition at line 140 of file MessageSvc.h.
StringArrayProperty MessageSvc::m_logColors[MSG::NUM_LEVELS] [private] |
Definition at line 137 of file MessageSvc.h.
Definition at line 169 of file MessageSvc.h.
Definition at line 167 of file MessageSvc.h.
MessageMap MessageSvc::m_messageMap [private] |
Message map.
Definition at line 129 of file MessageSvc.h.
boost::recursive_mutex MessageSvc::m_messageMapMutex [mutable, private] |
Mutex to synchronize multiple access to m_messageMap.
Definition at line 185 of file MessageSvc.h.
int MessageSvc::m_msgCount[MSG::NUM_LEVELS] [private] |
Definition at line 165 of file MessageSvc.h.
IntegerProperty MessageSvc::m_msgLimit[MSG::NUM_LEVELS] [private] |
Definition at line 138 of file MessageSvc.h.
boost::recursive_mutex MessageSvc::m_reportMutex [mutable, private] |
Mutex to synchronize multiple threads printing.
Definition at line 182 of file MessageSvc.h.
std::map<std::string,MsgAry> MessageSvc::m_sourceMap [private] |
Definition at line 158 of file MessageSvc.h.
Definition at line 136 of file MessageSvc.h.
BooleanProperty MessageSvc::m_stats [private] |
Definition at line 135 of file MessageSvc.h.
StreamMap MessageSvc::m_streamMap [private] |
Stream map.
Definition at line 128 of file MessageSvc.h.
BooleanProperty MessageSvc::m_suppress [private] |
Definition at line 159 of file MessageSvc.h.
ThresholdMap MessageSvc::m_thresholdMap [private] |
Output level threshold map.
Definition at line 130 of file MessageSvc.h.
boost::recursive_mutex MessageSvc::m_thresholdMapMutex [mutable, private] |
Mutex to synchronize multiple access to m_thresholdMap (.
Definition at line 189 of file MessageSvc.h.
StringArrayProperty MessageSvc::m_thresholdProp[MSG::NUM_LEVELS] [private] |
Properties controling.
Definition at line 133 of file MessageSvc.h.