8 #include "GaudiKernel/IMessageSvc.h"
9 #include "GaudiKernel/Message.h"
10 #include "GaudiKernel/Timing.h"
11 #include "GaudiKernel/Time.h"
12 #include "GaudiKernel/ContextSpecificPtr.h"
18 inline std::string formattedTime (
const std::string &fmt,
bool universal =
false )
34 m_ecThrd = pthread_self();
44 m_message( msg ), m_source( src ), m_type( type )
58 m_message(
std::move(msg) ), m_source(
std::move(src) ), m_type( type )
202 if (
LIKELY(!format.empty())) {
242 : std::move(timeFormat) );
254 auto i = format.begin();
255 while(
i != format.end() ) {
262 if (
i == format.end() )
break;
266 std::string this_format;
276 if (
i == format.end() ) {
294 if ( ! format.empty() ) {
295 const char FORMAT_TYPE = format[ format.length() - 1 ];
296 const std::string FORMAT_PARAM = format.substr( 0, format.length() - 1 );
300 switch( FORMAT_TYPE ) {
302 if ( FORMAT_PARAM.length() == 1 ) {
323 std::ostringstream ost;
325 ost <<
"0x" << std::hex <<
m_ecThrd;
326 const std::string& thrStr( ost.str() );
334 std::ostringstream ost;
336 const std::string& slotStr (ost.str());
339 const std::string& slotStr(
"" );
348 std::ostringstream ost;
350 const std::string& slotStr (ost.str());
353 const std::string& slotStr(
"" );
369 #define SET(x) case x: level=#x; break
377 case ALWAYS: level=
"SUCCESS";
break;
417 constexpr
struct all_digit_t {
418 template <
typename C>
419 bool operator()(
const C&
c)
const {
421 [](
typename C::const_reference
i) {
432 if ( all_digits(formatArg) )
m_width = std::stoi(formatArg);
446 if (
m_width == 0 ||
m_width == static_cast<int>( text.length() ) ) {
452 if (
m_width < static_cast<int>( text.length() ) ) {
453 newText = text.substr( 0,
m_width );
454 for (
int i = 0, j = newText.length()-1; i < 3 && j >= 0; ++
i, --j )
462 newText.replace( newText.begin(), newText.begin() + text.length(),
463 text.begin(), text.end() );
465 newText.replace( newText.end() - text.length(), newText.end(),
466 text.begin(), text.end() );
bool m_left
Justification.
const std::string & getFormat() const
Get the format string.
char m_fill
The current fill character.
static const char TYPE
The character used to indicate that the message type should be printed.
std::string m_formatted_msg
Formatted message.
std::string m_time_format
Time format string.
void decodeFormat(const std::string &format) const
Decode format.
static const char SLOT
For slot and event number from EventContext.
void setWidth(const std::string &formatArg) const
Set the width of a stream.
bool operator<(const Message &test)
Needed to build maps.
bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
static Time current(void)
Returns the current time.
auto begin(reverse_wrapper< T > &w)
static const char JUSTIFY_LEFT
The character used to indicate start of left text justification.
std::string m_message
The message.
void setMessage(std::string msg)
Set the message string.
void setType(int msg_type)
Set the message type.
int getType() const
Get the message type.
static constexpr const char * DEFAULT_FORMAT
The default message format.
static const char UTIME
The character used to indicate that the message timestamp should be printed in UTC time...
Message()
Default constructor.
void setSource(std::string src)
Set the message source.
void invalidFormat() const
Called when an invalid format string is encountered.
static const char FORMAT_PREFIX
Formatting string characters.
static const char FILL
The character used to indicate that the previous character is to be used for padding out fields if th...
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
static const std::string getDefaultTimeFormat()
Get the default time format string.
GAUDI_API ContextIdType currentContextId()
Return the current context id.
auto end(reverse_wrapper< T > &w)
std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
static const std::string getDefaultFormat()
Get the default format string.
static const char WIDTH
The character used to indicate that the previous decimal characters should be taken as the field widt...
GAUDI_API ContextIdType currentContextEvt()
static const char MESSAGE
The character used to indicate that the message should be printed.
int m_width
The current field width.
std::string m_format
The format string.
static const char TIME
The character used to indicate that the message timestamp should be printed.
void setFormat(std::string msg) const
Set the format string.
static const char JUSTIFY_RIGHT
The character used to indicate start of right text justification.
void makeFormattedMsg(const std::string &format) const
Format the message.
Print levels enumeration.
void setTimeFormat(std::string timeFormat) const
Set the time format string.
void sizeField(const std::string &text) const
Truncate or pad the output string to the field width as necessary.
const std::string & getSource() const
Get the message source.
const std::string & getTimeFormat() const
Get the time format string.
static const char SOURCE
The character used to indicate that the message source should be printed.
static constexpr const char * DEFAULT_TIME_FORMAT
The default time format.
std::string m_source
The source.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
const std::string & getMessage() const
Get the message string.