Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Message.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_MESSAGE_H
2 #define GAUDIKERNEL_MESSAGE_H
3 
5 #include "GaudiKernel/Kernel.h" // for GAUDI_API
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 
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};
98  mutable char m_fill{' '};
99  mutable int m_width{0};
100  mutable bool m_left{true};
101 
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 
164 
166 GAUDI_API bool operator==( const Message& a, const Message& b );
167 
168 #endif
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
std::string m_formatted_msg
Formatted message.
Definition: Message.h:97
ContextID_t slot() const
Definition: EventContext.h:48
std::string m_message
The message text.
Definition: Message.h:92
size_t ContextID_t
Definition: EventContext.h:33
ContextEvt_t evt() const
Definition: EventContext.h:47
STL class.
GAUDI_API const EventContext & currentContext()
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:245
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
Definition: Message.cpp:94
The Message class.
Definition: Message.h:17
GAUDI_API bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
Definition: Message.cpp:116
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:56
const EventIDBase & eventID() const
Definition: EventContext.h:52
#define GAUDI_API
Definition: Kernel.h:71
STL class.