Go to the documentation of this file.
48 : m_message(
std::move(
msg ) ), m_source(
std::move( src ) ), m_type(
type ) {}
105 msg.makeFormattedMsg(
msg.m_format );
238 switch ( FORMAT_TYPE ) {
240 if ( FORMAT_PARAM.
length() == 1 ) {
353 constexpr
struct all_digit_t {
354 template <
typename C>
355 bool operator()(
const C&
c )
const {
357 [](
typename C::const_reference i ) {
return isdigit( i ); } );
364 if ( all_digits( formatArg ) )
382 const size_t width =
static_cast<size_t>(
m_width );
384 if ( width < text.
length() ) {
385 if ( middle && width > 4 ) {
388 const size_t iDot = text.
rfind(
'.' );
389 if ( iDot != std::string::npos && width > text.
length() - iDot + 3 ) {
393 iTrunc = text.
length() - width / 2;
395 const size_t taillength = text.
length() - iTrunc;
396 const size_t frontlength = width - taillength - 3;
398 newText.
append( text, 0, frontlength );
400 newText.
append( text, iTrunc );
404 for (
int i = 0, j = newText.
length() - 1; i < 3 && j >= 0; ++i, --j ) newText[j] =
'.';
Print levels enumeration.
static const char FILL
The character used to indicate that the previous character is used to pad fields if the text is not l...
EventContext::ContextEvt_t m_ecEvt
Event number.
static constexpr const char * DEFAULT_FORMAT
The default message format.
static const char FORMAT_PREFIX
The character used to prefix formatting commands.
std::string m_format
The format string.
static const char TYPE
The character used to indicate that the message type should be printed.
char m_fill
Current fill character.
void setTimeFormat(std::string timeFormat) const
Set the time format string.
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.
const std::string & getMessage() const
Get the message string.
pthread_t m_ecThrd
Thread ID.
void sizeField(const std::string &text, bool middle=false) const
Truncate or pad the output string to the field width. If middle is true, cut the central part,...
static const char WIDTH
The character used to indicate that the previous decimal characters should be taken as the field widt...
static constexpr const char * DEFAULT_TIME_FORMAT
The default time format (accepts strftime formatters plus %f for milliseconds).
static constexpr ContextID_t INVALID_CONTEXT_ID
static const char EVENTID
The character used to indicate that the full event ID should be printed.
static const char EVTNUM
The character used to indicate that the event number should be printed.
bool m_left
The message alignment.
Message()=default
Default constructor.
std::ostream & operator<<(std::ostream &stream, const Message &msg)
const std::string & getFormat() const
Get the format string.
static const std::string getDefaultFormat()
Get the default format string.
int m_width
Current field width.
int m_type
The message type/level.
static const char UTIME
The character used to indicate that the message timestamp should be printed in UTC time.
void setMessage(std::string msg)
Set the message string.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
EventContext::ContextID_t m_ecSlot
Event slot.
static constexpr ContextEvt_t INVALID_CONTEXT_EVT
void setSource(std::string_view src)
Set the message source.
void setFormat(std::string msg) const
Set the format string.
void invalidFormat() const
Called when an invalid format string is encountered.
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
std::string m_message
The message text.
static const char TIME
The character used to indicate that the message timestamp should be printed.
bool operator==(const Message &a, const Message &b)
static const char JUSTIFY_LEFT
The character used to indicate start of left text justification.
static const char COMP
The character used to indicate that the message source should be printed, focus on the component.
std::string m_source
The message source.
static const char MESSAGE
The character used to indicate that the message should be printed.
static Time current()
Returns the current time.
const std::string & getSource() const
Get the message source.
static const char SLOT
The character used to indicate that the slot number should be printed.
static const char THREAD
The character used to indicate that the thread ID should be printed.
EventIDBase m_ecEvtId
Full event ID.
std::string m_formatted_msg
Formatted message.
std::string m_time_format
Time format string.
int getType() const
Get the message type.
void decodeFormat(const std::string &format) const
Decode format.
void setType(int msg_type)
Set the message type.
bool operator<(const Message &lhs, const Message &rhs)
void makeFormattedMsg(const std::string &format) const
Format the message.
void setWidth(const std::string &formatArg) const
Set the width of a stream.
static const char JUSTIFY_RIGHT
The character used to indicate start of right text justification.
static const std::string getDefaultTimeFormat()
Get the default time format string.