#include <GaudiKernel/Message.h>
|
|
| static const char | FORMAT_PREFIX = '%' |
| | The character used to prefix formatting commands. More...
|
| |
| static const char | JUSTIFY_LEFT = 'L' |
| | The character used to indicate start of left text justification. More...
|
| |
| static const char | JUSTIFY_RIGHT = 'R' |
| | The character used to indicate start of right text justification. More...
|
| |
| static const char | MESSAGE = 'M' |
| | The character used to indicate that the message should be printed. More...
|
| |
| static const char | TYPE = 'T' |
| | The character used to indicate that the message type should be printed. More...
|
| |
| static const char | TIME = 't' |
| | The character used to indicate that the message timestamp should be printed. More...
|
| |
| static const char | UTIME = 'u' |
| | The character used to indicate that the message timestamp should be printed in UTC time. More...
|
| |
| static const char | SOURCE = 'S' |
| | The character used to indicate that the message source should be printed. More...
|
| |
| static const char | COMP = 'C' |
| | The character used to indicate that the message source should be printed, focus on the component. More...
|
| |
| static const char | SLOT = 's' |
| | The character used to indicate that the slot number should be printed. More...
|
| |
| static const char | EVTNUM = 'e' |
| | The character used to indicate that the event number should be printed. More...
|
| |
| static const char | THREAD = 'X' |
| | The character used to indicate that the thread ID should be printed. More...
|
| |
| static const char | EVENTID = 'E' |
| | The character used to indicate that the full event ID should be printed. More...
|
| |
| static const char | FILL = 'F' |
| | The character used to indicate that the previous character is used to pad fields if the text is not long enough. More...
|
| |
| static const char | WIDTH = 'W' |
| | The character used to indicate that the previous decimal characters should be taken as the field width. More...
|
| |
| static constexpr const char * | DEFAULT_FORMAT = "% F%18W%S%7W%R%T %0W%M" |
| | The default message format. More...
|
| |
| static constexpr const char * | DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%f" |
| | The default time format (accepts strftime formatters plus %f for milliseconds). More...
|
| |
The Message class. This class is used to contain messages which can then be formatted and sent to a message service
- Author
- Iain Last
Definition at line 25 of file Message.h.
◆ Message() [1/3]
◆ Message() [2/3]
| Message::Message |
( |
const char * |
src, |
|
|
int |
type, |
|
|
const char * |
msg |
|
) |
| |
◆ Message() [3/3]
| Message::Message |
( |
std::string |
src, |
|
|
int |
type, |
|
|
std::string |
msg |
|
) |
| |
◆ ~Message()
◆ decodeFormat()
| void Message::decodeFormat |
( |
const std::string & |
format | ) |
const |
|
private |
Decode format.
Definition at line 159 of file Message.cpp.
162 const std::string FORMAT_PARAM =
format.substr( 0,
format.length() - 1 );
166 switch ( FORMAT_TYPE ) {
168 if ( FORMAT_PARAM.length() == 1 ) {
183 std::ostringstream ost;
186 const std::string& thrStr( ost.str() );
191 std::ostringstream ost;
197 std::ostringstream ost;
203 std::ostringstream ost;
◆ getDefaultFormat()
| static const std::string Message::getDefaultFormat |
( |
| ) |
|
|
inlinestatic |
Get the default format string.
Definition at line 68 of file Message.h.
◆ getDefaultTimeFormat()
| static const std::string Message::getDefaultTimeFormat |
( |
| ) |
|
|
inlinestatic |
Get the default time format string.
Definition at line 77 of file Message.h.
◆ getEventID()
◆ getEventNumber()
◆ getEventSlot()
◆ getFormat()
| const std::string& Message::getFormat |
( |
| ) |
const |
|
inline |
Get the format string.
Definition at line 65 of file Message.h.
◆ getMessage()
| const std::string& Message::getMessage |
( |
| ) |
const |
|
inline |
Get the message string.
Definition at line 40 of file Message.h.
◆ getSource()
| const std::string& Message::getSource |
( |
| ) |
const |
|
inline |
Get the message source.
Definition at line 52 of file Message.h.
◆ getTimeFormat()
| const std::string& Message::getTimeFormat |
( |
| ) |
const |
|
inline |
Get the time format string.
Definition at line 74 of file Message.h.
◆ getType()
| int Message::getType |
( |
| ) |
const |
|
inline |
Get the message type.
Definition at line 46 of file Message.h.
◆ invalidFormat()
| void Message::invalidFormat |
( |
| ) |
const |
|
private |
Called when an invalid format string is encountered.
Definition at line 271 of file Message.cpp.
◆ makeFormattedMsg()
| void Message::makeFormattedMsg |
( |
const std::string & |
format | ) |
const |
|
private |
Format the message.
Definition at line 122 of file Message.cpp.
125 while ( i !=
format.end() ) {
131 if ( i ==
format.end() )
break;
135 std::string this_format;
143 if ( i ==
format.end() ) {
◆ setFormat()
| void Message::setFormat |
( |
std::string |
msg | ) |
const |
Set the format string.
Definition at line 97 of file Message.cpp.
◆ setMessage()
| void Message::setMessage |
( |
std::string |
msg | ) |
|
|
inline |
Set the message string.
Definition at line 43 of file Message.h.
◆ setSource()
| void Message::setSource |
( |
std::string_view |
src | ) |
|
|
inline |
Set the message source.
Definition at line 55 of file Message.h.
◆ setTimeFormat()
| void Message::setTimeFormat |
( |
std::string |
timeFormat | ) |
const |
Set the time format string.
Definition at line 112 of file Message.cpp.
◆ setType()
| void Message::setType |
( |
int |
msg_type | ) |
|
|
inline |
Set the message type.
Definition at line 49 of file Message.h.
◆ setWidth()
| void Message::setWidth |
( |
const std::string & |
formatArg | ) |
const |
|
private |
Set the width of a stream.
Definition at line 290 of file Message.cpp.
292 if ( all_digits( formatArg ) )
293 m_width = std::stoi( formatArg );
◆ sizeField()
| void Message::sizeField |
( |
const std::string & |
text, |
|
|
bool |
middle = false |
|
) |
| const |
|
private |
Truncate or pad the output string to the field width. If middle is true, cut the central part, otherwise the end.
Definition at line 305 of file Message.cpp.
307 if (
m_width == 0 ||
m_width ==
static_cast<int>( text.length() ) ) {
310 const size_t width =
static_cast<size_t>(
m_width );
312 if ( width < text.length() ) {
313 if ( middle && width > 4 ) {
316 const size_t iDot = text.rfind(
'.' );
317 if ( iDot != std::string::npos && width > text.length() - iDot + 3 ) {
321 iTrunc = text.length() - width / 2;
323 const size_t taillength = text.length() - iTrunc;
324 const size_t frontlength = width - taillength - 3;
325 newText.reserve( width );
326 newText.append( text, 0, frontlength );
327 newText.append( 3,
'.' );
328 newText.append( text, iTrunc );
331 newText = text.substr( 0,
m_width );
332 for (
int i = 0,
j = newText.length() - 1; i < 3 && j >= 0; ++i, --
j ) newText[
j] =
'.';
339 newText.replace( newText.begin(), newText.begin() + text.length(), text.begin(), text.end() );
341 newText.replace( newText.end() - text.length(), newText.end(), text.begin(), text.end() );
◆ operator<
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
stream, |
|
|
const Message & |
msg |
|
) |
| |
|
friend |
Insert the message into a stream.
Definition at line 64 of file Message.cpp.
65 msg.makeFormattedMsg(
msg.m_format );
◆ operator==
Insert the message into a stream.
Definition at line 86 of file Message.cpp.
◆ COMP
| const char Message::COMP = 'C' |
|
staticprivate |
The character used to indicate that the message source should be printed, focus on the component.
Definition at line 152 of file Message.h.
◆ DEFAULT_FORMAT
| constexpr const char* Message::DEFAULT_FORMAT = "% F%18W%S%7W%R%T %0W%M" |
|
staticconstexprprivate |
The default message format.
Definition at line 174 of file Message.h.
◆ DEFAULT_TIME_FORMAT
| constexpr const char* Message::DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%f" |
|
staticconstexprprivate |
The default time format (accepts strftime formatters plus %f for milliseconds).
Definition at line 177 of file Message.h.
◆ EVENTID
| const char Message::EVENTID = 'E' |
|
staticprivate |
The character used to indicate that the full event ID should be printed.
Definition at line 164 of file Message.h.
◆ EVTNUM
| const char Message::EVTNUM = 'e' |
|
staticprivate |
The character used to indicate that the event number should be printed.
Definition at line 158 of file Message.h.
◆ FILL
| const char Message::FILL = 'F' |
|
staticprivate |
The character used to indicate that the previous character is used to pad fields if the text is not long enough.
Definition at line 167 of file Message.h.
◆ FORMAT_PREFIX
| const char Message::FORMAT_PREFIX = '%' |
|
staticprivate |
The character used to prefix formatting commands.
Definition at line 128 of file Message.h.
◆ JUSTIFY_LEFT
| const char Message::JUSTIFY_LEFT = 'L' |
|
staticprivate |
The character used to indicate start of left text justification.
Definition at line 131 of file Message.h.
◆ JUSTIFY_RIGHT
| const char Message::JUSTIFY_RIGHT = 'R' |
|
staticprivate |
The character used to indicate start of right text justification.
Definition at line 134 of file Message.h.
◆ m_ecEvt
◆ m_ecEvtId
◆ m_ecSlot
◆ m_ecThrd
| pthread_t Message::m_ecThrd {} |
|
private |
◆ m_fill
| char Message::m_fill { ' ' } |
|
mutableprivate |
Current fill character.
Definition at line 113 of file Message.h.
◆ m_format
The format string.
Definition at line 110 of file Message.h.
◆ m_formatted_msg
| std::string Message::m_formatted_msg |
|
mutableprivate |
Formatted message.
Definition at line 112 of file Message.h.
◆ m_left
| bool Message::m_left { true } |
|
mutableprivate |
The message alignment.
Definition at line 115 of file Message.h.
◆ m_message
| std::string Message::m_message |
|
private |
◆ m_source
| std::string Message::m_source { "UNKNOWN" } |
|
private |
The message source.
Definition at line 108 of file Message.h.
◆ m_time_format
Time format string.
Definition at line 111 of file Message.h.
◆ m_type
| int Message::m_type { 0 } |
|
private |
The message type/level.
Definition at line 109 of file Message.h.
◆ m_width
| int Message::m_width { 0 } |
|
mutableprivate |
Current field width.
Definition at line 114 of file Message.h.
◆ MESSAGE
| const char Message::MESSAGE = 'M' |
|
staticprivate |
The character used to indicate that the message should be printed.
Definition at line 137 of file Message.h.
◆ SLOT
| const char Message::SLOT = 's' |
|
staticprivate |
The character used to indicate that the slot number should be printed.
Definition at line 155 of file Message.h.
◆ SOURCE
| const char Message::SOURCE = 'S' |
|
staticprivate |
The character used to indicate that the message source should be printed.
Definition at line 149 of file Message.h.
◆ THREAD
| const char Message::THREAD = 'X' |
|
staticprivate |
The character used to indicate that the thread ID should be printed.
Definition at line 161 of file Message.h.
◆ TIME
| const char Message::TIME = 't' |
|
staticprivate |
The character used to indicate that the message timestamp should be printed.
Definition at line 143 of file Message.h.
◆ TYPE
| const char Message::TYPE = 'T' |
|
staticprivate |
The character used to indicate that the message type should be printed.
Definition at line 140 of file Message.h.
◆ UTIME
| const char Message::UTIME = 'u' |
|
staticprivate |
The character used to indicate that the message timestamp should be printed in UTC time.
Definition at line 146 of file Message.h.
◆ WIDTH
| const char Message::WIDTH = 'W' |
|
staticprivate |
The character used to indicate that the previous decimal characters should be taken as the field width.
Definition at line 170 of file Message.h.
The documentation for this class was generated from the following files:
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.
MsgStream & hex(MsgStream &log)
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.
GAUDI_API const EventContext & currentContext()
static const char SOURCE
The character used to indicate that the message source should be printed.
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.
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.
EventContext::ContextID_t m_ecSlot
Event slot.
static constexpr ContextEvt_t INVALID_CONTEXT_EVT
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.
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 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.
void decodeFormat(const std::string &format) const
Decode format.
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.