The Gaudi Framework  v40r0 (475e45c1)
MsgStream.h File Reference
#include <GaudiKernel/IMessageSvc.h>
#include <GaudiKernel/SerializeSTL.h>
#include <iomanip>
#include <sstream>
#include <string>
Include dependency graph for MsgStream.h:

Go to the source code of this file.

Classes

class  MsgStream
 

Namespaces

 MSG
 Print levels enumeration.
 

Functions

MsgStreamendmsg (MsgStream &s)
 MsgStream Modifier: endmsg. Calls the output method of the MsgStream. More...
 
GAUDI_API std::string format (const char *,...)
 MsgStream format utility "a la sprintf(...)". More...
 
template<class _Tm >
MsgStreamoperator<< (MsgStream &s, const std::smanip< _Tm > &manip)
 I/O Manipulator for setfill. More...
 
MsgStreamMSG::dec (MsgStream &log)
 
MsgStreamMSG::hex (MsgStream &log)
 
MsgStreamoperator<< (MsgStream &s, const char *arg)
 Specialization to avoid the generation of implementations for char[]. More...
 
template<typename T >
MsgStreamoperator<< (MsgStream &lhs, const T &arg)
 General templated stream operator. More...
 

Function Documentation

◆ endmsg()

MsgStream& endmsg ( MsgStream s)
inline

MsgStream Modifier: endmsg. Calls the output method of the MsgStream.

Definition at line 198 of file MsgStream.h.

198 { return s.doOutput(); }

◆ format()

GAUDI_API std::string format ( const char *  ,
  ... 
)

MsgStream format utility "a la sprintf(...)".

Definition at line 99 of file MsgStream.cpp.

99  {
100  const int buffsize = 2048;
101  static char buffer[buffsize];
102  va_list arguments;
103  va_start( arguments, fmt );
104  if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize ) {
105  va_end( arguments );
106  throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message",
107  "MsgStream", StatusCode::FAILURE );
108  }
109  va_end( arguments );
110  return std::string( buffer );
111 }

◆ operator<<() [1/3]

template<typename T >
MsgStream& operator<< ( MsgStream lhs,
const T &  arg 
)

General templated stream operator.

Definition at line 295 of file MsgStream.h.

295  {
296  using namespace GaudiUtils;
297  if ( lhs.isActive() ) try {
298  // this may throw, and we cannot afford it if the stream is used in a catch block
299  lhs.stream() << arg;
300  } catch ( ... ) {}
301  return lhs;
302 }

◆ operator<<() [2/3]

MsgStream& operator<< ( MsgStream s,
const char *  arg 
)
inline

Specialization to avoid the generation of implementations for char[].

See also
{bug #87340}

Definition at line 285 of file MsgStream.h.

285  {
286  try {
287  // this may throw, and we cannot afford it if the stream is used in a catch block
288  if ( s.isActive() ) s.stream() << arg;
289  } catch ( ... ) {}
290  return s;
291 }

◆ operator<<() [3/3]

template<class _Tm >
MsgStream& operator<< ( MsgStream s,
const std::smanip< _Tm > &  manip 
)
inline

I/O Manipulator for setfill.

Definition at line 263 of file MsgStream.h.

263  {
264  try {
265  // this may throw, and we cannot afford it if the stream is used in a catch block
266  if ( s.isActive() ) s.stream() << manip;
267  } catch ( ... ) {}
268  return s;
269 }
gaudirun.s
string s
Definition: gaudirun.py:346
GaudiException
Definition: GaudiException.h:29
fmt
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
GaudiUtils
Definition: Allocator.h:62
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:116
MsgStream::stream
std::ostringstream & stream()
Access string MsgStream.
Definition: MsgStream.h:99