|
Gaudi Framework, version v22r4 |
| Home | Generated: Fri Sep 2 2011 |
Definition of the MsgStream class used to transmit messages. More...
#include <GaudiKernel/MsgStream.h>

Public Member Functions | |
| GAUDI_API | MsgStream (IMessageSvc *svc, int buffer_length=128) |
| Standard constructor: Connect to message service for output. | |
| GAUDI_API | MsgStream (IMessageSvc *svc, const std::string &source, int buffer_length=128) |
| Standard constructor: Connect to message service for output. | |
| MsgStream (const MsgStream &msg) | |
| Copy constructor. | |
| virtual GAUDI_API | ~MsgStream () |
| Standard destructor. | |
| MsgStream & | report (int lvl) |
| Initialize report of new message: activate if print level is sufficient. | |
| virtual GAUDI_API MsgStream & | doOutput () |
| Output method. | |
| const std::string & | buffer () const |
| Access string buffer. | |
| std::ostringstream & | stream () |
| Access string MsgStream. | |
| void | setMsgSvc (IMessageSvc *svc) |
Update IMessageSvc pointer. | |
| void | setLevel (int level) |
| Update outputlevel. | |
| MSG::Level | level () |
| Retrieve output level. | |
| MSG::Level | currentLevel () |
| Retrieve current stream output level. | |
| void | activate () |
| Activate MsgStream. | |
| void | deactivate () |
| Deactivate MsgStream. | |
| bool | isActive () const |
| Accessor: is MsgStream active. | |
| MsgStream & | flush () |
| MsgStream & | write (const char *buff, int len) |
| MsgStream & | operator<< (MsgStream &(*_f)(MsgStream &)) |
| Accept MsgStream modifiers. | |
| MsgStream & | operator<< (std::ostream &(*_f)(std::ostream &)) |
| Accept oMsgStream modifiers. | |
| MsgStream & | operator<< (std::ios &(*_f)(std::ios &)) |
| Accept ios modifiers. | |
| MsgStream & | operator<< (MSG::Level level) |
| Accept MsgStream activation using MsgStreamer operator. | |
| MsgStream & | operator<< (longlong arg) |
| MsgStream & | operator<< (std::ios_base &(*_f)(std::ios_base &)) |
| Accept ios base class modifiers. | |
| long | flags () const |
| IOS emulation. | |
| long | flags (FLAG_TYPE v) |
| long | setf (FLAG_TYPE v) |
| int | width () const |
| int | width (int v) |
| char | fill () const |
| char | fill (char v) |
| int | precision () const |
| int | precision (int v) |
| int | rdstate () const |
| int | good () const |
| int | eof () const |
| int | bad () const |
| long | setf (FLAG_TYPE _f, FLAG_TYPE _m) |
| void | unsetf (FLAG_TYPE _l) |
| void | clear (STATE_TYPE _i=std::ios_base::failbit) |
| GAUDI_API void | setColor (MSG::Color col) |
| Set the text color. | |
| GAUDI_API void | setColor (MSG::Color fg, MSG::Color bg) |
| Set the foreground and background colors. | |
| GAUDI_API void | resetColor () |
| Reset the colors to defaults. | |
Static Public Member Functions | |
| static GAUDI_API bool | enableCountInactive (bool value=true) |
| Enable/disable the count of inactive messages. | |
| static GAUDI_API bool | countInactive () |
| Returns the state of the counting of inactive messages (enabled/disabled). | |
Protected Attributes | |
| IMessageSvc * | m_service |
| Pointer to message service if buffer has send. | |
| std::string | m_buffer |
| Use standard string for information buffering. | |
| std::string | m_source |
| Use std::string for source information to be passed to the message service. | |
| std::ostringstream | m_stream |
| String MsgStream associated to buffer. | |
| bool | m_active |
| Flag set to true if formatting engine is active. | |
| MSG::Level | m_level |
| Debug level of the message service. | |
| MSG::Level | m_currLevel |
| Current debug level. | |
| bool | m_useColors |
| use colors | |
| IInactiveMessageCounter * | m_inactCounter |
| Pointer to service counting messages prepared but not printed because of wrong level. | |
Static Protected Attributes | |
| static bool | m_countInactive = false |
| Flag to state if the inactive messages has to be counted. | |
Private Types | |
| typedef std::ios_base::fmtflags | FLAG_TYPE |
| Error return code in case ios modification is requested for inactive streams. | |
| typedef std::ios_base::iostate | STATE_TYPE |
Definition of the MsgStream class used to transmit messages.
This class is intended to ease the use of error logging to the message service
Definition at line 24 of file MsgStream.h.
typedef std::ios_base::fmtflags MsgStream::FLAG_TYPE [private] |
Error return code in case ios modification is requested for inactive streams.
Definition at line 29 of file MsgStream.h.
typedef std::ios_base::iostate MsgStream::STATE_TYPE [private] |
Definition at line 30 of file MsgStream.h.
| MsgStream::MsgStream | ( | IMessageSvc * | svc, |
| int | buffer_length = 128 |
||
| ) |
Standard constructor: Connect to message service for output.
Definition at line 43 of file MsgStream.cpp.
: m_service(svc), m_source(""), m_active(false), m_inactCounter(0) { setLevel((0==svc) ? MSG::INFO : svc->outputLevel()); m_useColors = (0==svc) ? false : svc->useColor(); #ifndef NDEBUG m_inactCounter = svc ? Gaudi::Cast<IInactiveMessageCounter>(svc) : 0; #endif }
| MsgStream::MsgStream | ( | IMessageSvc * | svc, |
| const std::string & | source, | ||
| int | buffer_length = 128 |
||
| ) |
Standard constructor: Connect to message service for output.
Definition at line 56 of file MsgStream.cpp.
: m_service(svc), m_source(source), m_active(false), m_inactCounter(0) { setLevel((0==svc) ? MSG::INFO : svc->outputLevel(source)); m_useColors = (0==svc) ? false : svc->useColor(); #ifndef NDEBUG m_inactCounter = svc ? Gaudi::Cast<IInactiveMessageCounter>(svc) : 0; #endif }
| MsgStream::MsgStream | ( | const MsgStream & | msg ) | [inline] |
Copy constructor.
Definition at line 60 of file MsgStream.h.
: m_service(msg.m_service), m_active(msg.m_active), m_level(msg.m_level), m_useColors(msg.m_useColors), m_inactCounter(msg.m_inactCounter) { try { // ignore exception if we cannot copy the string m_source = msg.m_source; } catch (...) {} }
| MsgStream::~MsgStream | ( | ) | [virtual] |
| void MsgStream::activate | ( | ) | [inline] |
| int MsgStream::bad | ( | ) | const [inline] |
Definition at line 212 of file MsgStream.h.
| const std::string& MsgStream::buffer | ( | ) | const [inline] |
| void MsgStream::clear | ( | STATE_TYPE | _i = std::ios_base::failbit ) |
[inline] |
Definition at line 221 of file MsgStream.h.
| bool MsgStream::countInactive | ( | ) | [static] |
Returns the state of the counting of inactive messages (enabled/disabled).
Definition at line 38 of file MsgStream.cpp.
{
return m_countInactive;
}
| MSG::Level MsgStream::currentLevel | ( | ) | [inline] |
Retrieve current stream output level.
Definition at line 115 of file MsgStream.h.
{
return m_currLevel;
}
| void MsgStream::deactivate | ( | ) | [inline] |
| MsgStream & MsgStream::doOutput | ( | ) | [virtual] |
Output method.
Definition at line 72 of file MsgStream.cpp.
{
try {
// This piece of code may throw and we cannot afford it when we print a message
// in the middle of a catch block.
if ( isActive() ) {
Message msg(m_source,m_currLevel,m_stream.str());
if ( m_service != 0 ) {
m_service->reportMessage (msg, m_currLevel);
}
else {
std::cout << msg << std::endl;
}
}
m_stream.str("");
} catch(...) {}
return *this;
}
Enable/disable the count of inactive messages.
Returns the previous state.
Definition at line 32 of file MsgStream.cpp.
{
bool old = m_countInactive;
m_countInactive = value;
return old;
}
| int MsgStream::eof | ( | ) | const [inline] |
Definition at line 209 of file MsgStream.h.
| char MsgStream::fill | ( | ) | const [inline] |
Definition at line 191 of file MsgStream.h.
| char MsgStream::fill | ( | char | v ) | [inline] |
Definition at line 194 of file MsgStream.h.
| long MsgStream::flags | ( | ) | const [inline] |
IOS emulation.
Definition at line 176 of file MsgStream.h.
Definition at line 179 of file MsgStream.h.
| MsgStream& MsgStream::flush | ( | ) | [inline] |
Definition at line 131 of file MsgStream.h.
| int MsgStream::good | ( | ) | const [inline] |
Definition at line 206 of file MsgStream.h.
| bool MsgStream::isActive | ( | ) | const [inline] |
| MSG::Level MsgStream::level | ( | ) | [inline] |
| MsgStream& MsgStream::operator<< | ( | std::ios_base &(*)(std::ios_base &) | _f ) | [inline] |
Accept ios base class modifiers.
Definition at line 170 of file MsgStream.h.
Accept ios modifiers.
Definition at line 151 of file MsgStream.h.
| MsgStream& MsgStream::operator<< | ( | MSG::Level | level ) | [inline] |
Accept MsgStream activation using MsgStreamer operator.
Definition at line 156 of file MsgStream.h.
Definition at line 159 of file MsgStream.h.
| MsgStream& MsgStream::operator<< | ( | std::ostream &(*)(std::ostream &) | _f ) | [inline] |
Accept oMsgStream modifiers.
Definition at line 146 of file MsgStream.h.
Accept MsgStream modifiers.
Definition at line 141 of file MsgStream.h.
{
if ( isActive() ) _f(*this);
return *this;
}
| int MsgStream::precision | ( | int | v ) | [inline] |
Definition at line 200 of file MsgStream.h.
| int MsgStream::precision | ( | ) | const [inline] |
Definition at line 197 of file MsgStream.h.
| int MsgStream::rdstate | ( | ) | const [inline] |
Definition at line 203 of file MsgStream.h.
{
return isActive() ? m_stream.rdstate () : std::ios_base::failbit;
}
| MsgStream& MsgStream::report | ( | int | lvl ) | [inline] |
Initialize report of new message: activate if print level is sufficient.
Definition at line 75 of file MsgStream.h.
{
lvl = (lvl >= MSG::NUM_LEVELS) ?
MSG::ALWAYS : (lvl<MSG::NIL) ? MSG::NIL : lvl;
if ((m_currLevel=MSG::Level(lvl)) >= level()) {
activate();
} else {
deactivate();
#ifndef NDEBUG
if (MsgStream::countInactive() && m_inactCounter) {
m_inactCounter->incrInactiveCount(MSG::Level(lvl),m_source);
}
#endif
}
return *this;
}
| void MsgStream::resetColor | ( | ) |
Reset the colors to defaults.
Definition at line 117 of file MsgStream.cpp.
{
#ifndef _WIN32
if ( m_useColors ) {
try { // this may throw and we must not do it
m_stream << "[m" << m_service->getLogColor(m_currLevel);
}
catch(...) {}
}
#endif
}
| void MsgStream::setColor | ( | MSG::Color | col ) |
Set the text color.
Definition at line 90 of file MsgStream.cpp.
{
#ifndef _WIN32
if ( m_useColors) {
int fc = 90 + col;
try { // this may throw and we must not do it
m_stream << "[" << fc << ";1m";
}
catch(...) {}
}
#endif
}
| void MsgStream::setColor | ( | MSG::Color | fg, |
| MSG::Color | bg | ||
| ) |
Set the foreground and background colors.
Definition at line 102 of file MsgStream.cpp.
{
#ifndef _WIN32
if ( m_useColors ) {
try { // this may throw and we must not do it
int fc = 90 + fg;
m_stream << "[" << fc;
int bc = 100 + bg;
m_stream << ";" << bc;
m_stream << ";1m";
}
catch(...) {}
}
#endif
}
Definition at line 215 of file MsgStream.h.
Definition at line 182 of file MsgStream.h.
| void MsgStream::setLevel | ( | int | level ) | [inline] |
Update outputlevel.
Definition at line 105 of file MsgStream.h.
{
level = (level >= MSG::NUM_LEVELS) ?
MSG::ALWAYS : (level<MSG::NIL) ? MSG::NIL : level;
m_level = MSG::Level(level);
}
| void MsgStream::setMsgSvc | ( | IMessageSvc * | svc ) | [inline] |
| std::ostringstream& MsgStream::stream | ( | ) | [inline] |
| void MsgStream::unsetf | ( | FLAG_TYPE | _l ) | [inline] |
Definition at line 218 of file MsgStream.h.
| int MsgStream::width | ( | ) | const [inline] |
Definition at line 185 of file MsgStream.h.
| int MsgStream::width | ( | int | v ) | [inline] |
Definition at line 188 of file MsgStream.h.
| MsgStream& MsgStream::write | ( | const char * | buff, |
| int | len | ||
| ) | [inline] |
Definition at line 136 of file MsgStream.h.
bool MsgStream::m_active [protected] |
Flag set to true if formatting engine is active.
Definition at line 41 of file MsgStream.h.
std::string MsgStream::m_buffer [protected] |
Use standard string for information buffering.
Definition at line 35 of file MsgStream.h.
bool MsgStream::m_countInactive = false [static, protected] |
Flag to state if the inactive messages has to be counted.
Definition at line 52 of file MsgStream.h.
MSG::Level MsgStream::m_currLevel [protected] |
Current debug level.
Definition at line 45 of file MsgStream.h.
IInactiveMessageCounter* MsgStream::m_inactCounter [protected] |
Pointer to service counting messages prepared but not printed because of wrong level.
Definition at line 50 of file MsgStream.h.
MSG::Level MsgStream::m_level [protected] |
Debug level of the message service.
Definition at line 43 of file MsgStream.h.
IMessageSvc* MsgStream::m_service [protected] |
Pointer to message service if buffer has send.
Definition at line 33 of file MsgStream.h.
std::string MsgStream::m_source [protected] |
Use std::string for source information to be passed to the message service.
Definition at line 37 of file MsgStream.h.
std::ostringstream MsgStream::m_stream [protected] |
String MsgStream associated to buffer.
Definition at line 39 of file MsgStream.h.
bool MsgStream::m_useColors [protected] |
use colors
Definition at line 47 of file MsgStream.h.