|
Gaudi Framework, version v21r8 |
| Home | Generated: 17 Mar 2010 |
#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. | |
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 | |
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 |
This class is intended to ease the use of error logging to the message service
Definition at line 25 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 30 of file MsgStream.h.
typedef std::ios_base::iostate MsgStream::STATE_TYPE [private] |
Definition at line 31 of file MsgStream.h.
| MsgStream::MsgStream | ( | IMessageSvc * | svc, | |
| int | buffer_length = 128 | |||
| ) |
Standard constructor: Connect to message service for output.
Definition at line 31 of file MsgStream.cpp.
00032 : m_service(svc), 00033 m_source(""), 00034 m_active(false) 00035 { 00036 setLevel((0==svc) ? MSG::INFO : svc->outputLevel()); 00037 m_useColors = (0==svc) ? false : svc->useColor(); 00038 }
| MsgStream::MsgStream | ( | IMessageSvc * | svc, | |
| const std::string & | source, | |||
| int | buffer_length = 128 | |||
| ) |
Standard constructor: Connect to message service for output.
Definition at line 40 of file MsgStream.cpp.
00041 : m_service(svc), 00042 m_source(source), 00043 m_active(false) 00044 { 00045 setLevel((0==svc) ? MSG::INFO : svc->outputLevel(source)); 00046 m_useColors = (0==svc) ? false : svc->useColor(); 00047 }
| MsgStream::MsgStream | ( | const MsgStream & | msg | ) | [inline] |
Copy constructor.
Definition at line 55 of file MsgStream.h.
00056 : m_service(msg.m_service), 00057 m_active(msg.m_active), 00058 m_level(msg.m_level), 00059 m_useColors(msg.m_useColors) 00060 { 00061 try { // ignore exception if we cannot copy the string 00062 m_source = msg.m_source; 00063 } 00064 catch (...) {} 00065 }
| MsgStream::~MsgStream | ( | ) | [virtual] |
| MsgStream& MsgStream::report | ( | int | lvl | ) | [inline] |
Initialize report of new message: activate if print level is sufficient.
Definition at line 69 of file MsgStream.h.
00069 { 00070 lvl = (lvl >= MSG::NUM_LEVELS) ? 00071 MSG::ALWAYS : (lvl<MSG::NIL) ? MSG::NIL : lvl; 00072 ((m_currLevel=MSG::Level(lvl)) >= level()) ? activate() : deactivate(); 00073 return *this; 00074 }
| MsgStream & MsgStream::doOutput | ( | ) | [virtual] |
Output method.
Definition at line 52 of file MsgStream.cpp.
00052 { 00053 try { 00054 // This piece of code may throw and we cannot afford it when we print a message 00055 // in the middle of a catch block. 00056 if ( isActive() ) { 00057 Message msg(m_source,m_currLevel,m_stream.str()); 00058 if ( m_service != 0 ) { 00059 m_service->reportMessage (msg, m_currLevel); 00060 } 00061 else { 00062 std::cout << msg << std::endl; 00063 } 00064 } 00065 m_stream.str(""); 00066 } catch(...) {} 00067 return *this; 00068 }
| const std::string& MsgStream::buffer | ( | ) | const [inline] |
Access string buffer.
Definition at line 78 of file MsgStream.h.
00078 { 00079 return m_buffer; 00080 }
| std::ostringstream& MsgStream::stream | ( | ) | [inline] |
Access string MsgStream.
Definition at line 82 of file MsgStream.h.
00082 { 00083 return m_stream; 00084 }
| void MsgStream::setMsgSvc | ( | IMessageSvc * | svc | ) | [inline] |
Update IMessageSvc pointer.
Definition at line 86 of file MsgStream.h.
00086 { 00087 m_service = svc; 00088 }
| void MsgStream::setLevel | ( | int | level | ) | [inline] |
Update outputlevel.
Definition at line 90 of file MsgStream.h.
00090 { 00091 level = (level >= MSG::NUM_LEVELS) ? 00092 MSG::ALWAYS : (level<MSG::NIL) ? MSG::NIL : level; 00093 m_level = MSG::Level(level); 00094 }
| MSG::Level MsgStream::level | ( | ) | [inline] |
Retrieve output level.
Definition at line 96 of file MsgStream.h.
00096 { 00097 return m_level; 00098 }
| MSG::Level MsgStream::currentLevel | ( | ) | [inline] |
Retrieve current stream output level.
Definition at line 100 of file MsgStream.h.
00100 { 00101 return m_currLevel; 00102 }
| void MsgStream::activate | ( | ) | [inline] |
Activate MsgStream.
Definition at line 104 of file MsgStream.h.
00104 { 00105 m_active = true; 00106 }
| void MsgStream::deactivate | ( | ) | [inline] |
Deactivate MsgStream.
Definition at line 108 of file MsgStream.h.
00108 { 00109 m_active = false; 00110 }
| bool MsgStream::isActive | ( | ) | const [inline] |
Accessor: is MsgStream active.
Definition at line 112 of file MsgStream.h.
00112 { 00113 return m_active; 00114 }
| MsgStream& MsgStream::flush | ( | ) | [inline] |
| MsgStream& MsgStream::write | ( | const char * | buff, | |
| int | len | |||
| ) | [inline] |
Accept MsgStream modifiers.
Definition at line 126 of file MsgStream.h.
00126 { 00127 if ( isActive() ) _f(*this); 00128 return *this; 00129 }
| MsgStream& MsgStream::operator<< | ( | std::ostream &(*)(std::ostream &) | _f | ) | [inline] |
| MsgStream& MsgStream::operator<< | ( | MSG::Level | level | ) | [inline] |
Definition at line 144 of file MsgStream.h.
00144 { 00145 try { 00146 // this may throw, and we cannot afford it if the stream is used in a catch block 00147 if(isActive()) { 00148 #ifdef _WIN32 00149 int flg = m_stream.flags(); 00150 char buf[128]; 00151 (flg & std::ios::hex) ? 00152 ::sprintf(buf,"%I64x",arg) : ::sprintf(buf,"%I64d",arg); 00153 m_stream << buf; 00154 #else 00155 m_stream << arg; 00156 #endif 00157 } 00158 } catch (...) {} 00159 return *this; 00160 }
| MsgStream& MsgStream::operator<< | ( | std::ios_base &(*)(std::ios_base &) | _f | ) | [inline] |
| long MsgStream::flags | ( | ) | const [inline] |
| int MsgStream::width | ( | ) | const [inline] |
| int MsgStream::width | ( | int | v | ) | [inline] |
| char MsgStream::fill | ( | ) | const [inline] |
| char MsgStream::fill | ( | char | v | ) | [inline] |
| int MsgStream::precision | ( | ) | const [inline] |
| int MsgStream::precision | ( | int | v | ) | [inline] |
| int MsgStream::rdstate | ( | ) | const [inline] |
Definition at line 196 of file MsgStream.h.
00196 { 00197 return isActive() ? m_stream.rdstate () : std::ios_base::failbit; 00198 }
| int MsgStream::good | ( | ) | const [inline] |
| int MsgStream::eof | ( | ) | const [inline] |
| int MsgStream::bad | ( | ) | const [inline] |
| void MsgStream::unsetf | ( | FLAG_TYPE | _l | ) | [inline] |
| void MsgStream::clear | ( | STATE_TYPE | _i = std::ios_base::failbit |
) | [inline] |
| void MsgStream::setColor | ( | MSG::Color | col | ) |
Set the text color.
Definition at line 70 of file MsgStream.cpp.
00070 { 00071 #ifndef _WIN32 00072 if ( m_useColors) { 00073 int fc = 90 + col; 00074 try { // this may throw and we must not do it 00075 m_stream << "[" << fc << ";1m"; 00076 } 00077 catch(...) {} 00078 } 00079 #endif 00080 }
| void MsgStream::setColor | ( | MSG::Color | fg, | |
| MSG::Color | bg | |||
| ) |
Set the foreground and background colors.
Definition at line 82 of file MsgStream.cpp.
00082 { 00083 #ifndef _WIN32 00084 if ( m_useColors ) { 00085 try { // this may throw and we must not do it 00086 int fc = 90 + fg; 00087 m_stream << "[" << fc; 00088 int bc = 100 + bg; 00089 m_stream << ";" << bc; 00090 m_stream << ";1m"; 00091 } 00092 catch(...) {} 00093 } 00094 #endif 00095 }
| void MsgStream::resetColor | ( | ) |
Reset the colors to defaults.
Definition at line 97 of file MsgStream.cpp.
00097 { 00098 #ifndef _WIN32 00099 if ( m_useColors ) { 00100 try { // this may throw and we must not do it 00101 m_stream << "[m" << m_service->getLogColor(m_currLevel); 00102 } 00103 catch(...) {} 00104 } 00105 #endif 00106 }
IMessageSvc* MsgStream::m_service [protected] |
std::string MsgStream::m_buffer [protected] |
std::string MsgStream::m_source [protected] |
Use std::string for source information to be passed to the message service.
Definition at line 38 of file MsgStream.h.
std::ostringstream MsgStream::m_stream [protected] |
bool MsgStream::m_active [protected] |
MSG::Level MsgStream::m_level [protected] |
MSG::Level MsgStream::m_currLevel [protected] |
bool MsgStream::m_useColors [protected] |