The Gaudi Framework
v33r0 (d5ea422b)
Message.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#ifndef GAUDIKERNEL_MESSAGE_H
12
#define GAUDIKERNEL_MESSAGE_H
13
14
#include "
GaudiKernel/EventContext.h
"
15
#include "
GaudiKernel/Kernel.h
"
// for GAUDI_API
16
#include "
GaudiKernel/ThreadLocalContext.h
"
17
#include <iostream>
18
#include <string>
19
27
class
GAUDI_API
Message
final {
28
public
:
30
Message
() =
default
;
31
33
Message
(
const
char
* src,
int
type
,
const
char
*
msg
);
34
36
Message
(
std::string
src,
int
type
,
std::string
msg
);
37
39
~
Message
() =
default
;
40
42
const
std::string
& getMessage()
const
;
43
45
void
setMessage(
std::string
msg
);
46
48
int
getType()
const
;
49
51
void
setType(
int
msg_type );
52
54
const
std::string
& getSource()
const
;
55
57
void
setSource(
std::string
src );
58
60
const
std::string
& getFormat()
const
;
61
63
static
const
std::string
getDefaultFormat();
64
66
void
setFormat(
std::string
msg
)
const
;
67
69
const
std::string
& getTimeFormat()
const
;
70
72
static
const
std::string
getDefaultTimeFormat();
73
75
void
setTimeFormat(
std::string
timeFormat )
const
;
76
78
bool
operator<
(
const
Message
&
test
);
79
81
friend
std::ostream
&
operator<<
(
std::ostream
& stream,
const
Message
&
msg
);
82
84
friend
bool
operator==
(
const
Message
& a,
const
Message
& b );
85
86
private
:
88
void
invalidFormat()
const
;
89
91
void
makeFormattedMsg(
const
std::string
&
format
)
const
;
92
94
void
decodeFormat(
const
std::string
&
format
)
const
;
95
97
void
sizeField(
const
std::string
& text )
const
;
98
100
void
setWidth(
const
std::string
& formatArg )
const
;
101
102
std::string
m_message
;
103
std::string
m_source{
"UNKNOWN"
};
104
int
m_type{0};
105
mutable
std::string
m_format{DEFAULT_FORMAT};
106
mutable
std::string
m_time_format{DEFAULT_TIME_FORMAT};
107
mutable
std::string
m_formatted_msg
;
108
mutable
char
m_fill{
' '
};
109
mutable
int
m_width{0};
110
mutable
bool
m_left{
true
};
111
114
EventContext::ContextID_t
m_ecSlot{
Gaudi::Hive::currentContext
().
slot
()};
115
EventContext::ContextEvt_t
m_ecEvt{
Gaudi::Hive::currentContext
().
evt
()};
116
EventIDBase
m_ecEvtId{
Gaudi::Hive::currentContext
().
eventID
()};
117
pthread_t m_ecThrd{pthread_self()};
118
119
122
static
const
char
FORMAT_PREFIX =
'%'
;
124
126
static
const
char
JUSTIFY_LEFT =
'L'
;
127
129
static
const
char
JUSTIFY_RIGHT =
'R'
;
130
132
static
const
char
MESSAGE =
'M'
;
133
135
static
const
char
TYPE =
'T'
;
136
138
static
const
char
TIME =
't'
;
139
141
static
const
char
UTIME =
'u'
;
142
144
static
const
char
SOURCE =
'S'
;
145
147
static
const
char
SLOT =
's'
;
148
150
static
const
char
EVTNUM =
'e'
;
151
153
static
const
char
THREAD =
'X'
;
154
156
static
const
char
EVENTID =
'E'
;
157
159
static
const
char
FILL =
'F'
;
160
162
static
const
char
WIDTH =
'W'
;
164
166
static
constexpr
const
char
* DEFAULT_FORMAT =
"% F%18W%S%7W%R%T %0W%M"
;
167
169
static
constexpr
const
char
* DEFAULT_TIME_FORMAT =
"%Y-%m-%d %H:%M:%S,%f"
;
170
};
171
173
GAUDI_API
std::ostream
&
operator<<
(
std::ostream
& stream,
const
Message
&
msg
);
174
176
GAUDI_API
bool
operator==
(
const
Message
& a,
const
Message
& b );
177
178
#endif
Kernel.h
EventContext::slot
ContextID_t slot() const
Definition:
EventContext.h:51
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition:
MsgStream.cpp:119
Message::m_formatted_msg
std::string m_formatted_msg
Formatted message.
Definition:
Message.h:107
EventContext::evt
ContextEvt_t evt() const
Definition:
EventContext.h:50
ThreadLocalContext.h
Message::m_message
std::string m_message
The message text.
Definition:
Message.h:102
EventContext.h
std::size_t
EventContext::ContextID_t
size_t ContextID_t
Definition:
EventContext.h:36
std::string
STL class.
compareRootHistos.test
string test
Definition:
compareRootHistos.py:26
gaudirun.type
type
Definition:
gaudirun.py:154
Gaudi::Hive::currentContext
GAUDI_API const EventContext & currentContext()
Definition:
ThreadLocalContext.cpp:30
operator<
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition:
EventIDBase.h:255
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Message &msg)
Insert the message into a stream.
Definition:
Message.cpp:104
Message
The Message class.
Definition:
Message.h:27
operator==
GAUDI_API bool operator==(const Message &a, const Message &b)
Insert the message into a stream.
Definition:
Message.cpp:126
GaudiMP.FdsRegistry.msg
msg
Definition:
FdsRegistry.py:18
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition:
EventIDBase.h:66
GAUDI_API
#define GAUDI_API
Definition:
Kernel.h:81
std::ostream
STL class.
EventContext::eventID
const EventIDBase & eventID() const
Definition:
EventContext.h:55
GaudiKernel
GaudiKernel
Message.h
Generated on Mon Dec 16 2019 23:26:33 for The Gaudi Framework by
1.8.15