The Gaudi Framework  master (37c0b60a)
MsgStream.cpp File Reference
#include <GaudiKernel/GaudiException.h>
#include <GaudiKernel/IMessageSvc.h>
#include <GaudiKernel/Message.h>
#include <GaudiKernel/MsgStream.h>
#include <cstdarg>
#include <cstdio>
#include <iostream>
Include dependency graph for MsgStream.cpp:

Go to the source code of this file.

Macros

#define KERNEL_MSGSTREAM_CPP
 

Functions

std::string format (const char *fmt,...)
 MsgStream format utility "a la sprintf(...)". More...
 

Macro Definition Documentation

◆ KERNEL_MSGSTREAM_CPP

#define KERNEL_MSGSTREAM_CPP

Definition at line 29 of file MsgStream.cpp.

Function Documentation

◆ format()

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

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

Definition at line 119 of file MsgStream.cpp.

119  {
120  const int buffsize = 2048;
121  static char buffer[buffsize];
122  va_list arguments;
123  va_start( arguments, fmt );
124  if ( vsnprintf( buffer, buffsize, fmt, arguments ) >= buffsize ) {
125  va_end( arguments );
126  throw GaudiException( "Insufficient buffer size (" + std::to_string( buffsize ) + ") when formatting message",
127  "MsgStream", StatusCode::FAILURE );
128  }
129  va_end( arguments );
130  return std::string( buffer );
131 }
std::string
STL class.
GaudiException
Definition: GaudiException.h:31
std::to_string
T to_string(T... args)
fmt
std::vsnprintf
T vsnprintf(T... args)
va_list
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101