| The Gaudi Framework v32r1 (f65d50dc)

Message.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_MESSAGE_H
2 #define GAUDIKERNEL_MESSAGE_H
3
4 #include "GaudiKernel/EventContext.h"
5 #include "GaudiKernel/Kernel.h" // for GAUDI_API
6 #include "GaudiKernel/ThreadLocalContext.h"
7 #include <iostream>
8 #include <string>
9
17 class GAUDI_API Message final {
18 public:
20 Message() = default;
21
23 Message( const char* src, int type, const char* msg );
24
26 Message( std::string src, int type, std::string msg );
27
29 ~Message() = default;
30
32 const std::string& getMessage() const;
33
35 void setMessage( std::string msg );
36
38 int getType() const;
39
41 void setType( int msg_type );
42
44 const std::string& getSource() const;
45
47 void setSource( std::string src );
48
50 const std::string& getFormat() const;
51
53 static const std::string getDefaultFormat();
54
56 void setFormat( std::string msg ) const;
57
59 const std::string& getTimeFormat() const;
60
62 static const std::string getDefaultTimeFormat();
63
65 void setTimeFormat( std::string timeFormat ) const;
66
68 bool operator<( const Message& test );
69
71 friend std::ostream& operator<<( std::ostream& stream, const Message& msg );
72
74 friend bool operator==( const Message& a, const Message& b );
75
76 private:
78 void invalidFormat() const;
79
81 void makeFormattedMsg( const std::string& format ) const;
82
84 void decodeFormat( const std::string& format ) const;
85
87 void sizeField( const std::string& text ) const;
88
90 void setWidth( const std::string& formatArg ) const;
91
92 std::string m_message;
93 std::string m_source{"UNKNOWN"};
94 int m_type{0};
95 mutable std::string m_format{DEFAULT_FORMAT};
96 mutable std::string m_time_format{DEFAULT_TIME_FORMAT};
97 mutable std::string m_formatted_msg;
98 mutable char m_fill{' '};
99 mutable int m_width{0};
100 mutable bool m_left{true};
101
104 EventContext::ContextID_t m_ecSlot{Gaudi::Hive::currentContext().slot()};
105 EventContext::ContextEvt_t m_ecEvt{Gaudi::Hive::currentContext().evt()};
106 EventIDBase m_ecEvtId{Gaudi::Hive::currentContext().eventID()};
107 pthread_t m_ecThrd{pthread_self()};
108
109
112 static const char FORMAT_PREFIX = '%';
114
116 static const char JUSTIFY_LEFT = 'L';
117
119 static const char JUSTIFY_RIGHT = 'R';
120
122 static const char MESSAGE = 'M';
123
125 static const char TYPE = 'T';
126
128 static const char TIME = 't';
129
131 static const char UTIME = 'u';
132
134 static const char SOURCE = 'S';
135
137 static const char SLOT = 's';
138
140 static const char EVTNUM = 'e';
141
143 static const char THREAD = 'X';
144
146 static const char EVENTID = 'E';
147
149 static const char FILL = 'F';
150
152 static const char WIDTH = 'W';
154
156 static constexpr const char* DEFAULT_FORMAT = "% F%18W%S%7W%R%T %0W%M";
157
159 static constexpr const char* DEFAULT_TIME_FORMAT = "%Y-%m-%d %H:%M:%S,%f";
160 };
161
163 GAUDI_API std::ostream& operator<<( std::ostream& stream, const Message& msg );
164
166 GAUDI_API bool operator==( const Message& a, const Message& b );
167
168 #endif
Kernel.h
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
Message::m_formatted_msg
std::string m_formatted_msg
Formatted message.
Definition: Message.h:97
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:40
ThreadLocalContext.h
Message::m_message
std::string m_message
The message text.
Definition: Message.h:92
EventContext.h
std::size_t
EventContext::ContextID_t
size_t ContextID_t
Definition: EventContext.h:26
std::string
STL class.
compareRootHistos.test
string test
Definition: compareRootHistos.py:15
gaudirun.type
type
Definition: gaudirun.py:142
Gaudi::Hive::currentContext
GAUDI_API const EventContext & currentContext()
Definition: ThreadLocalContext.cpp:20
operator<
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:245
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
Definition: Message.cpp:94
Message
The Message class.
Definition: Message.h:17
operator==
GAUDI_API bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
Definition: Message.cpp:116
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:56
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
std::ostream
STL class.
EventContext::eventID
const EventIDBase & eventID() const
Definition: EventContext.h:45