| The Gaudi Framework v28r2-patches (bc4ad17a)

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

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

Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Types | List of all members
MsgStream Class Reference

Definition of the MsgStream class used to transmit messages. More...

`#include <GaudiKernel/MsgStream.h>`

Collaboration diagram for MsgStream:
[legend]

## Public Member Functions
GAUDI_API | MsgStream (IMessageSvc *svc, int buffer_length=128)
| Standard constructor: Connect to message service for output. More...
GAUDI_API | MsgStream (IMessageSvc *svc, std::string source, int buffer_length=128)
| Standard constructor: Connect to message service for output. More...
| MsgStream (const MsgStream &msg)
| Copy constructor. More...
virtual GAUDI_API | ~MsgStream ()=default
| Standard destructor. More...
MsgStream & | report (int lvl)
| Initialize report of new message: activate if print level is sufficient. More...
virtual GAUDI_API MsgStream & | doOutput ()
| Output method. More...
const std::string & | buffer () const
| Access string buffer. More...
std::ostringstream & | stream ()
| Access string MsgStream. More...
void | setMsgSvc (IMessageSvc *svc)
| Update `IMessageSvc` pointer. More...
void | setLevel (int level)
| Update outputlevel. More...
MSG::Level | level ()
| Retrieve output level. More...
MSG::Level | currentLevel ()
| Retrieve current stream output level. More...
void | activate ()
| Activate MsgStream. More...
void | deactivate ()
| Deactivate MsgStream. More...
bool | isActive () const
| Accessor: is MsgStream active. More...
MsgStream & | flush ()
MsgStream & | write (const char *buff, int len)
MsgStream & | operator<< (MsgStream &(*_f)(MsgStream &))
| Accept MsgStream modifiers. More...
MsgStream & | operator<< (std::ostream &(*_f)(std::ostream &))
| Accept oMsgStream modifiers. More...
MsgStream & | operator<< (std::ios &(*_f)(std::ios &))
| Accept ios modifiers. More...
MsgStream & | operator<< (MSG::Level level)
| Accept MsgStream activation using MsgStreamer operator. More...
MsgStream & | operator<< (longlong arg)
MsgStream & | operator<< (std::ios_base &(*_f)(std::ios_base &))
| Accept ios base class modifiers. More...
long | flags () const
| IOS emulation. More...
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. More...
GAUDI_API void | setColor (MSG::Color fg, MSG::Color bg)
| Set the foreground and background colors. More...
GAUDI_API void | resetColor ()
| Reset the colors to defaults. More...

## Static Public Member Functions
static GAUDI_API bool | enableCountInactive (bool value=true)
| Enable/disable the count of inactive messages. More...
static GAUDI_API bool | countInactive ()
| Returns the state of the counting of inactive messages (enabled/disabled). More...

## Protected Attributes
IMessageSvc * | m_service
| Pointer to message service if buffer has send. More...
std::string | m_buffer
| Use standard string for information buffering. More...
std::string | m_source
| Use std::string for source information to be passed to the message service. More...
std::ostringstream | m_stream
| String MsgStream associated to buffer. More...
bool | m_active = false
| Flag set to true if formatting engine is active. More...
MSG::Level | m_level
| Debug level of the message service. More...
MSG::Level | m_currLevel
| Current debug level. More...
bool | m_useColors
| use colors More...
IInactiveMessageCounter * | m_inactCounter = nullptr
| Pointer to service counting messages prepared but not printed because of wrong level. More...

## Static Protected Attributes
static bool | m_countInactive = false
| Flag to state if the inactive messages has to be counted. More...

## Private Types
typedef std::ios_base::fmtflags | FLAG_TYPE
| Error return code in case ios modification is requested for inactive streams. More...
typedef std::ios_base::iostate | STATE_TYPE

## Detailed Description

Definition of the MsgStream class used to transmit messages.

This class is intended to ease the use of error logging to the message service

Author
  M.Frank
  Sebastien Ponce

Definition at line 24 of file MsgStream.h.

## Member Typedef Documentation

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.

## Constructor & Destructor Documentation

MsgStream::MsgStream | ( | IMessageSvc * | svc,
|  | int | buffer_length = `128`
| ) |  |

Standard constructor: Connect to message service for output.

Definition at line 43 of file MsgStream.cpp.

44 : m_service(svc)
45 {
46 setLevel( svc ? svc->outputLevel() : MSG::INFO );
47 m_useColors = ( svc ? svc->useColor() : false );
48 #ifndef NDEBUG
49 m_inactCounter = svc ? Gaudi::Cast<IInactiveMessageCounter>(svc) : 0;
50 #endif
51 }
IMessageSvc::useColor
virtual bool useColor() const =0
Show whether colors are used.
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33
MsgStream::setLevel
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
MsgStream::m_inactCounter
IInactiveMessageCounter * m_inactCounter
Pointer to service counting messages prepared but not printed because of wrong level.
Definition: MsgStream.h:50
MSG::INFO
Definition: IMessageSvc.h:19
IMessageSvc::outputLevel
virtual int outputLevel() const =0
Retrieve the current output level threshold.

MsgStream::MsgStream | ( | IMessageSvc * | svc,
|  | std::string | source,
|  | int | buffer_length = `128`
| ) |  |

Standard constructor: Connect to message service for output.

Definition at line 53 of file MsgStream.cpp.

54 : m_service(svc),
55 m_source(std::move(source))
56 {
57 setLevel( svc ? svc->outputLevel(m_source) : MSG::INFO );
58 m_useColors = ( svc && svc->useColor() );
59 #ifndef NDEBUG
60 m_inactCounter = svc ? Gaudi::Cast<IInactiveMessageCounter>(svc) : 0;
61 #endif
62 }
IMessageSvc::useColor
virtual bool useColor() const =0
Show whether colors are used.
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33
MsgStream::m_source
std::string m_source
Use std::string for source information to be passed to the message service.
Definition: MsgStream.h:37
std::move
T move(T...args)
MsgStream::setLevel
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
MsgStream::m_inactCounter
IInactiveMessageCounter * m_inactCounter
Pointer to service counting messages prepared but not printed because of wrong level.
Definition: MsgStream.h:50
MSG::INFO
Definition: IMessageSvc.h:19
IMessageSvc::outputLevel
virtual int outputLevel() const =0
Retrieve the current output level threshold.

MsgStream::MsgStream | ( | const MsgStream & | msg | ) |
| inline

Copy constructor.

Definition at line 60 of file MsgStream.h.

61 : m_service(msg.m_service),
62 m_active(msg.m_active),
63 m_level(msg.m_level),
64 m_currLevel(msg.m_currLevel),
65 m_useColors(msg.m_useColors),
66 m_inactCounter(msg.m_inactCounter)
67 {
68 try { // ignore exception if we cannot copy the string
69 m_source = msg.m_source;
70 }
71 catch (...) {}
72 }
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33
MsgStream::m_source
std::string m_source
Use std::string for source information to be passed to the message service.
Definition: MsgStream.h:37
MsgStream::m_level
MSG::Level m_level
Debug level of the message service.
Definition: MsgStream.h:43
MsgStream::m_active
bool m_active
Flag set to true if formatting engine is active.
Definition: MsgStream.h:41
MsgStream::m_currLevel
MSG::Level m_currLevel
Current debug level.
Definition: MsgStream.h:45
MsgStream::m_inactCounter
IInactiveMessageCounter * m_inactCounter
Pointer to service counting messages prepared but not printed because of wrong level.
Definition: MsgStream.h:50

virtual GAUDI_API MsgStream::~MsgStream | ( |  | ) |
| virtual default

Standard destructor.

## Member Function Documentation

void MsgStream::activate | ( |  | ) |
| inline

Activate MsgStream.

Definition at line 120 of file MsgStream.h.

120 {
121 m_active = true;
122 }
MsgStream::m_active
bool m_active
Flag set to true if formatting engine is active.
Definition: MsgStream.h:41

int MsgStream::bad | ( |  | ) | const
| inline

Definition at line 213 of file MsgStream.h.

213 {
214 return isActive() ? m_stream.bad() : 0;
215 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::bad
T bad(T...args)

const std::string& MsgStream::buffer | ( |  | ) | const
| inline

Access string buffer.

Definition at line 94 of file MsgStream.h.

94 {
95 return m_buffer;
96 }
MsgStream::m_buffer
std::string m_buffer
Use standard string for information buffering.
Definition: MsgStream.h:35

void MsgStream::clear | ( | STATE_TYPE | _i = `std::ios_base::failbit` | ) |
| inline

Definition at line 222 of file MsgStream.h.

222 {
223 if ( isActive() ) m_stream.clear(_i);
224 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::clear
T clear(T...args)

bool MsgStream::countInactive | ( |  | ) |
| static

Returns the state of the counting of inactive messages (enabled/disabled).

Definition at line 38 of file MsgStream.cpp.

38 {
39 return m_countInactive;
40 }
MsgStream::m_countInactive
static bool m_countInactive
Flag to state if the inactive messages has to be counted.
Definition: MsgStream.h:52

MSG::Level MsgStream::currentLevel | ( |  | ) |
| inline

Retrieve current stream output level.

Definition at line 116 of file MsgStream.h.

116 {
117 return m_currLevel;
118 }
MsgStream::m_currLevel
MSG::Level m_currLevel
Current debug level.
Definition: MsgStream.h:45

void MsgStream::deactivate | ( |  | ) |
| inline

Deactivate MsgStream.

Definition at line 124 of file MsgStream.h.

124 {
125 m_active = false;
126 }
MsgStream::m_active
bool m_active
Flag set to true if formatting engine is active.
Definition: MsgStream.h:41

MsgStream & MsgStream::doOutput | ( |  | ) |
| virtual

Output method.

Definition at line 64 of file MsgStream.cpp.

64 {
65 try {
66 // This piece of code may throw and we cannot afford it when we print a message
67 // in the middle of a catch block.
68 if ( isActive() ) {
69 const Message msg(m_source, m_currLevel,m_stream.str());
70 if ( m_service ) {
71 m_service->reportMessage (msg, m_currLevel);
72 } else {
73 std::cout << msg << std::endl;
74 }
75 }
76 m_stream.str("");
77 } catch(...) {}
78 return *this;
79 }
std::endl
T endl(T...args)
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33
MsgStream::m_source
std::string m_source
Use std::string for source information to be passed to the message service.
Definition: MsgStream.h:37
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::str
T str(T...args)
MsgStream::m_currLevel
MSG::Level m_currLevel
Current debug level.
Definition: MsgStream.h:45
Message
The Message class.
Definition: Message.h:15
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
IMessageSvc::reportMessage
virtual void reportMessage(const Message &msg, int outputLevel)=0
Report a message by sending a Message object to the message service.
std::cout

bool MsgStream::enableCountInactive | ( | bool | value = `true` | ) |
| static

Enable/disable the count of inactive messages.

Returns the previous state.

Definition at line 32 of file MsgStream.cpp.

32 {
33 bool old = m_countInactive;
34 m_countInactive = value;
35 return old;
36 }
MsgStream::m_countInactive
static bool m_countInactive
Flag to state if the inactive messages has to be counted.
Definition: MsgStream.h:52

int MsgStream::eof | ( |  | ) | const
| inline

Definition at line 210 of file MsgStream.h.

210 {
211 return isActive() ? m_stream.eof () : 0;
212 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::eof
T eof(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

char MsgStream::fill | ( |  | ) | const
| inline

Definition at line 192 of file MsgStream.h.

192 {
193 return isActive() ? m_stream.fill() : (char)-1;
194 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::fill
T fill(T...args)

char MsgStream::fill | ( | char | v | ) |
| inline

Definition at line 195 of file MsgStream.h.

195 {
196 return isActive() ? m_stream.fill(v) : (char)-1;
197 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::fill
T fill(T...args)

long MsgStream::flags | ( |  | ) | const
| inline

IOS emulation.

Definition at line 177 of file MsgStream.h.

177 {
178 return isActive() ? m_stream.flags() : 0;
179 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::flags
T flags(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

long MsgStream::flags | ( | FLAG_TYPE | v | ) |
| inline

Definition at line 180 of file MsgStream.h.

180 {
181 return isActive() ? m_stream.flags(v) : 0;
182 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::flags
T flags(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

MsgStream& MsgStream::flush | ( |  | ) |
| inline

Definition at line 132 of file MsgStream.h.

132 {
133 if ( isActive() ) m_stream.flush();
134 return *this;
135 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::flush
T flush(T...args)

int MsgStream::good | ( |  | ) | const
| inline

Definition at line 207 of file MsgStream.h.

207 {
208 return isActive() ? m_stream.good () : 0;
209 }
std::ostringstream::good
T good(T...args)
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

bool MsgStream::isActive | ( |  | ) | const
| inline

Accessor: is MsgStream active.

Definition at line 128 of file MsgStream.h.

128 {
129 return m_active;
130 }
MsgStream::m_active
bool m_active
Flag set to true if formatting engine is active.
Definition: MsgStream.h:41

MSG::Level MsgStream::level | ( |  | ) |
| inline

Retrieve output level.

Definition at line 112 of file MsgStream.h.

112 {
113 return m_level;
114 }
MsgStream::m_level
MSG::Level m_level
Debug level of the message service.
Definition: MsgStream.h:43

MsgStream& MsgStream::operator<< | ( | MsgStream &(*)(MsgStream &) | _f | ) |
| inline

Accept MsgStream modifiers.

Definition at line 142 of file MsgStream.h.

142 {
143 if ( isActive() ) _f(*this);
144 return *this;
145 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128

MsgStream& MsgStream::operator<< | ( | std::ostream &(*)(std::ostream &) | _f | ) |
| inline

Accept oMsgStream modifiers.

Definition at line 147 of file MsgStream.h.

147 {
148 if ( isActive() ) _f(m_stream);
149 return *this;
150 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

MsgStream& MsgStream::operator<< | ( | std::ios &(*)(std::ios &) | _f | ) |
| inline

Accept ios modifiers.

Definition at line 152 of file MsgStream.h.

152 {
153 if ( isActive() ) _f(m_stream);
154 return *this;
155 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

MsgStream& MsgStream::operator<< | ( | MSG::Level | level | ) |
| inline

Accept MsgStream activation using MsgStreamer operator.

Definition at line 157 of file MsgStream.h.

157 {
158 return report(level);
159 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MsgStream::report
MsgStream & report(int lvl)
Initialize report of new message: activate if print level is sufficient.
Definition: MsgStream.h:76

MsgStream& MsgStream::operator<< | ( | longlong | arg | ) |
| inline

Definition at line 160 of file MsgStream.h.

160 {
161 try {
162 // this may throw, and we cannot afford it if the stream is used in a catch block
163 if(isActive()) {
164 m_stream << arg;
165 }
166 } catch (...) {}
167 return *this;
168 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

MsgStream& MsgStream::operator<< | ( | std::ios_base &(*)(std::ios_base &) | _f | ) |
| inline

Accept ios base class modifiers.

Definition at line 171 of file MsgStream.h.

171 {
172 if ( isActive() ) _f(m_stream);
173 return *this;
174 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

int MsgStream::precision | ( |  | ) | const
| inline

Definition at line 198 of file MsgStream.h.

198 {
199 return isActive() ? m_stream.precision(): 0;
200 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::precision
T precision(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

int MsgStream::precision | ( | int | v | ) |
| inline

Definition at line 201 of file MsgStream.h.

201 {
202 return isActive() ? m_stream.precision(v): 0;
203 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::precision
T precision(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

int MsgStream::rdstate | ( |  | ) | const
| inline

Definition at line 204 of file MsgStream.h.

204 {
205 return isActive() ? m_stream.rdstate () : std::ios_base::failbit;
206 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::ostringstream::rdstate
T rdstate(T...args)
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

MsgStream& MsgStream::report | ( | int | lvl | ) |
| inline

Initialize report of new message: activate if print level is sufficient.

Definition at line 76 of file MsgStream.h.

76 {
77 lvl = (lvl >= MSG::NUM_LEVELS) ?
78 MSG::ALWAYS : (lvl<MSG::NIL) ? MSG::NIL : lvl;
79 if ((m_currLevel=MSG::Level(lvl)) >= level()) {
80 activate();
81 } else {
82 deactivate();
83 #ifndef NDEBUG
84 if (MsgStream::countInactive() && m_inactCounter) {
85 m_inactCounter->incrInactiveCount(MSG::Level(lvl),m_source);
86 }
87 #endif
88 }
89 return *this;
90 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
IInactiveMessageCounter::incrInactiveCount
virtual void incrInactiveCount(MSG::Level level, const std::string &src)=0
Increment deactivated message count.
MsgStream::m_source
std::string m_source
Use std::string for source information to be passed to the message service.
Definition: MsgStream.h:37
MSG::Level
Level
Definition: IMessageSvc.h:15
MsgStream::deactivate
void deactivate()
Deactivate MsgStream.
Definition: MsgStream.h:124
MSG::NIL
Definition: IMessageSvc.h:16
MsgStream::m_currLevel
MSG::Level m_currLevel
Current debug level.
Definition: MsgStream.h:45
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MsgStream::activate
void activate()
Activate MsgStream.
Definition: MsgStream.h:120
MsgStream::m_inactCounter
IInactiveMessageCounter * m_inactCounter
Pointer to service counting messages prepared but not printed because of wrong level.
Definition: MsgStream.h:50
MSG::ALWAYS
Definition: IMessageSvc.h:23
MsgStream::countInactive
static GAUDI_API bool countInactive()
Returns the state of the counting of inactive messages (enabled/disabled).
Definition: MsgStream.cpp:38

void MsgStream::resetColor | ( |  | ) |

Reset the colors to defaults.

Definition at line 108 of file MsgStream.cpp.

108 {
109 #ifndef _WIN32
110 if ( m_useColors ) {
111 try { // this may throw and we must not do it
112 m_stream << "\x1b[m" << m_service->getLogColor(m_currLevel);
113 }
114 catch(...) {}
115 }
116 #endif
117 }
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33
IMessageSvc::getLogColor
virtual std::string getLogColor(int logLevel) const =0
Get the color codes for various log levels.
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
MsgStream::m_currLevel
MSG::Level m_currLevel
Current debug level.
Definition: MsgStream.h:45

void MsgStream::setColor | ( | MSG::Color | col | ) |

Set the text color.

Definition at line 81 of file MsgStream.cpp.

81 {
82 #ifndef _WIN32
83 if ( m_useColors) {
84 int fc = 90 + col;
85 try { // this may throw and we must not do it
86 m_stream << "\x1b[" << fc << ";1m";
87 }
88 catch(...) {}
89 }
90 #endif
91 }
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

void MsgStream::setColor | ( | MSG::Color | fg,
|  | MSG::Color | bg
| ) |  |

Set the foreground and background colors.

Definition at line 93 of file MsgStream.cpp.

93 {
94 #ifndef _WIN32
95 if ( m_useColors ) {
96 try { // this may throw and we must not do it
97 int fc = 90 + fg;
98 m_stream << "\x1b[" << fc;
99 int bc = 100 + bg;
100 m_stream << ";" << bc;
101 m_stream << ";1m";
102 }
103 catch(...) {}
104 }
105 #endif
106 }
MsgStream::m_useColors
bool m_useColors
use colors
Definition: MsgStream.h:47
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

long MsgStream::setf | ( | FLAG_TYPE | v | ) |
| inline

Definition at line 183 of file MsgStream.h.

183 {
184 return isActive() ? m_stream.setf(v) : 0;
185 }
std::ostringstream::setf
T setf(T...args)
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

long MsgStream::setf | ( | FLAG_TYPE | _f,
|  | FLAG_TYPE | _m
| ) |  |
| inline

Definition at line 216 of file MsgStream.h.

216 {
217 return isActive() ? m_stream.setf(_f, _m) : 0;
218 }
std::ostringstream::setf
T setf(T...args)
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

void MsgStream::setLevel | ( | int | level | ) |
| inline

Update outputlevel.

Definition at line 106 of file MsgStream.h.

106 {
107 level = (level >= MSG::NUM_LEVELS) ?
108 MSG::ALWAYS : (level<MSG::NIL) ? MSG::NIL : level;
109 m_level = MSG::Level(level);
110 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MsgStream::m_level
MSG::Level m_level
Debug level of the message service.
Definition: MsgStream.h:43
MSG::Level
Level
Definition: IMessageSvc.h:15
MSG::NIL
Definition: IMessageSvc.h:16
MSG::NUM_LEVELS
Definition: IMessageSvc.h:24
MSG::ALWAYS
Definition: IMessageSvc.h:23

void MsgStream::setMsgSvc | ( | IMessageSvc * | svc | ) |
| inline

Update `IMessageSvc` pointer.

Definition at line 102 of file MsgStream.h.

102 {
103 m_service = svc;
104 }
MsgStream::m_service
IMessageSvc * m_service
Pointer to message service if buffer has send.
Definition: MsgStream.h:33

std::ostringstream& MsgStream::stream | ( |  | ) |
| inline

Access string MsgStream.

Definition at line 98 of file MsgStream.h.

98 {
99 return m_stream;
100 }
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39

void MsgStream::unsetf | ( | FLAG_TYPE | _l | ) |
| inline

Definition at line 219 of file MsgStream.h.

219 {
220 if ( isActive() ) m_stream.unsetf(_l);
221 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::unsetf
T unsetf(T...args)

int MsgStream::width | ( |  | ) | const
| inline

Definition at line 186 of file MsgStream.h.

186 {
187 return isActive() ? m_stream.width() : 0;
188 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::width
T width(T...args)

int MsgStream::width | ( | int | v | ) |
| inline

Definition at line 189 of file MsgStream.h.

189 {
190 return isActive() ? m_stream.width(v) : 0;
191 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::width
T width(T...args)

MsgStream& MsgStream::write | ( | const char * | buff,
|  | int | len
| ) |  |
| inline

Definition at line 137 of file MsgStream.h.

137 {
138 if ( isActive() ) m_stream.write(buff, len);
139 return *this;
140 }
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
MsgStream::m_stream
std::ostringstream m_stream
String MsgStream associated to buffer.
Definition: MsgStream.h:39
std::ostringstream::write
T write(T...args)

## Member Data Documentation

bool MsgStream::m_active = false
| 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 = nullptr
| 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.

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

- GaudiKernel/GaudiKernel/MsgStream.h
- GaudiKernel/src/Lib/MsgStream.cpp