OnixS C++ CME MDP Premium Market Data Handler 5.10.3
Users' manual and API documentation
Loading...
Searching...
No Matches
LogEvents.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
27
29
31
40{
41public:
44 : entry_(entry)
45 , message_(entry.message())
46 {
47 entry_.category(category);
48 entry_.source(source);
49 }
50
53 {
54 entry_.commit();
55 }
56
58 std::string& message()
59 {
60 return message_;
61 }
62
64 const std::string& message() const
65 {
66 return message_;
67 }
68
69private:
70 LogEntry& entry_;
71 std::string& message_;
72
73 // Object copying is not assumed.
74
75 LogEvent(const LogEvent&);
76 LogEvent& operator=(const LogEvent&);
77};
78
79// A few descendants for a particular purposes.
80
83{
85 LogError(LogEntry& entry, const Messaging::Char* source)
86 : LogEvent(entry, LogCategory::Error, Messaging::toStrRef(source))
87 {
88 }
89
92 : LogEvent(entry, LogCategory::Error, source)
93 {
94 }
95
97 LogError(LogEntry& entry, const std::string& source)
98 : LogEvent(entry, LogCategory::Error, Messaging::toStrRef(source))
99 {
100 }
101};
102
105{
107 LogWarning(LogEntry& entry, const Messaging::Char* source)
108 : LogEvent(entry, LogCategory::Warning, Messaging::toStrRef(source))
109 {
110 }
111
114 : LogEvent(entry, LogCategory::Warning, source)
115 {
116 }
117
119 LogWarning(LogEntry& entry, const std::string& source)
120 : LogEvent(entry, LogCategory::Warning, Messaging::toStrRef(source))
121 {
122 }
123};
124
127{
129 LogInfo(LogEntry& entry, const Messaging::Char* source)
130 : LogEvent(entry, LogCategory::Info, Messaging::toStrRef(source))
131 {
132 }
133
136 : LogEvent(entry, LogCategory::Info, source)
137 {
138 }
139
141 LogInfo(LogEntry& entry, const std::string& source)
142 : LogEvent(entry, LogCategory::Info, Messaging::toStrRef(source))
143 {
144 }
145};
146
149{
151 LogDebug(LogEntry& entry, const Messaging::Char* source)
152 : LogEvent(entry, LogCategory::Debug, Messaging::toStrRef(source))
153 {
154 }
155
158 : LogEvent(entry, LogCategory::Debug, source)
159 {
160 }
161
163 LogDebug(LogEntry& entry, const std::string& source)
164 : LogEvent(entry, LogCategory::Debug, Messaging::toStrRef(source))
165 {
166 }
167};
168
169// Sugar-coat for adding basic type data to log entry.
170
173template <typename Undefined>
174LogEvent& operator<<(LogEvent& event, Undefined undefined)
175{
176 struct DefineOperatorForGivenType
177 {
178 } var = undefined;
179
180 return event;
181}
182
184inline LogEvent& operator<<(LogEvent& event, const Messaging::Char* cStr)
185{
186 event.message() += cStr;
187
188 return event;
189}
190
192inline LogEvent& operator<<(LogEvent& event, const std::string& str)
193{
194 event.message() += str;
195
196 return event;
197}
198
201{
202 Messaging::toStr(event.message(), strRef);
203
204 return event;
205}
206
208inline LogEvent& operator<<(LogEvent& event, Messaging::Char character)
209{
210 event.message() += character;
211
212 return event;
213}
214
217{
218 Messaging::toStr(event.message(), number);
219
220 return event;
221}
222
225{
226 Messaging::toStr(event.message(), number);
227
228 return event;
229}
230
233{
234 Messaging::toStr(event.message(), number);
235
236 return event;
237}
238
241{
242 Messaging::toStr(event.message(), number);
243
244 return event;
245}
246
249{
250 Messaging::toStr(event.message(), number);
251
252 return event;
253}
254
257{
258 Messaging::toStr(event.message(), number);
259
260 return event;
261}
262
265{
266 Messaging::toStr(event.message(), number);
267
268 return event;
269}
270
273{
274 Messaging::toStr(event.message(), number);
275
276 return event;
277}
278
280template <class Mantissa, class Exponent>
282{
283 toStr(event.message(), number);
284
285 return event;
286}
287
288// Logs timestamp.
290{
291 toStr(event.message(), timestamp);
292
293 return event;
294}
295
297inline LogEvent& operator<<(LogEvent& event, const Messaging::TimeSpan& timeSpan)
298{
299 toStr(event.message(), timeSpan);
300
301 return event;
302}
303
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:54
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:55
Abstraction of log entry in logging services.
Definition Logger.h:122
std::string & message()
Informational message to be added to a log.
Definition LogEvents.h:58
~LogEvent()
Commits entry to the log.
Definition LogEvents.h:52
const std::string & message() const
Informational message to be added to a log.
Definition LogEvents.h:64
LogEvent(LogEntry &entry, LogCategory::Enum category, Messaging::StrRef source)
Initializes event with LogEntry instance.
Definition LogEvents.h:43
The time point without the time-zone information.
Definition Time.h:455
std::uint32_t UInt32
uInt32.
Definition Integral.h:35
std::int8_t Int8
int8.
Definition Integral.h:30
char Char
Character type alias.
Definition String.h:30
std::uint16_t UInt16
uInt16.
Definition Integral.h:33
std::int32_t Int32
int32.
Definition Integral.h:34
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
std::uint64_t UInt64
uInt64.
Definition Integral.h:37
void toStr(std::string &, Int8)
Serializes given integer into a string.
std::uint8_t UInt8
uInt8.
Definition Integral.h:31
std::int16_t Int16
int16.
Definition Integral.h:32
Messaging::Timestamp timestamp(const Messaging::FIX::MultiContainer &, Messaging::FIX::Tag)
Retrieves last update time field value.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
std::ostream & operator<<(std::ostream &stream, const IssueArgs &args)
Categories for information being logged.
Definition Logger.h:81
Enum
Categories for information being logged.
Definition Logger.h:87
LogDebug(LogEntry &entry, const Messaging::Char *source)
Initializes event as debug information.
Definition LogEvents.h:151
LogDebug(LogEntry &entry, Messaging::StrRef source)
Initializes event as debug information.
Definition LogEvents.h:157
LogDebug(LogEntry &entry, const std::string &source)
Initializes event as debug information.
Definition LogEvents.h:163
LogError(LogEntry &entry, Messaging::StrRef source)
Initializes event as error.
Definition LogEvents.h:91
LogError(LogEntry &entry, const std::string &source)
Initializes event as error.
Definition LogEvents.h:97
LogError(LogEntry &entry, const Messaging::Char *source)
Initializes event as error.
Definition LogEvents.h:85
LogInfo(LogEntry &entry, Messaging::StrRef source)
Initializes event as information.
Definition LogEvents.h:135
LogInfo(LogEntry &entry, const std::string &source)
Initializes event as information.
Definition LogEvents.h:141
LogInfo(LogEntry &entry, const Messaging::Char *source)
Initializes event as information.
Definition LogEvents.h:129
LogWarning(LogEntry &entry, Messaging::StrRef source)
Initializes event as warning.
Definition LogEvents.h:113
LogWarning(LogEntry &entry, const std::string &source)
Initializes event as warning.
Definition LogEvents.h:119
LogWarning(LogEntry &entry, const Messaging::Char *source)
Initializes event as warning.
Definition LogEvents.h:107