OnixS C++ CME MDP Premium Market Data Handler 5.11.1
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
55 std::string& message()
56 {
57 return message_;
58 }
59
61 const std::string& message() const
62 {
63 return message_;
64 }
65
66private:
67 LogEntry& entry_;
68 std::string& message_;
69
70 // Object copying is not assumed.
71
72 LogEvent(const LogEvent&);
73 LogEvent& operator=(const LogEvent&);
74};
75
76// A few descendants for a particular purposes.
77
80{
82 LogError(LogEntry& entry, const Messaging::Char* source)
83 : LogEvent(entry, LogCategory::Error, Messaging::toStrRef(source))
84 {
85 }
86
89 : LogEvent(entry, LogCategory::Error, source)
90 {
91 }
92
94 LogError(LogEntry& entry, const std::string& source)
95 : LogEvent(entry, LogCategory::Error, Messaging::toStrRef(source))
96 {
97 }
98};
99
102{
104 LogWarning(LogEntry& entry, const Messaging::Char* source)
105 : LogEvent(entry, LogCategory::Warning, Messaging::toStrRef(source))
106 {
107 }
108
111 : LogEvent(entry, LogCategory::Warning, source)
112 {
113 }
114
116 LogWarning(LogEntry& entry, const std::string& source)
117 : LogEvent(entry, LogCategory::Warning, Messaging::toStrRef(source))
118 {
119 }
120};
121
124{
126 LogInfo(LogEntry& entry, const Messaging::Char* source)
127 : LogEvent(entry, LogCategory::Info, Messaging::toStrRef(source))
128 {
129 }
130
133 : LogEvent(entry, LogCategory::Info, source)
134 {
135 }
136
138 LogInfo(LogEntry& entry, const std::string& source)
139 : LogEvent(entry, LogCategory::Info, Messaging::toStrRef(source))
140 {
141 }
142};
143
146{
148 LogDebug(LogEntry& entry, const Messaging::Char* source)
149 : LogEvent(entry, LogCategory::Debug, Messaging::toStrRef(source))
150 {
151 }
152
155 : LogEvent(entry, LogCategory::Debug, source)
156 {
157 }
158
160 LogDebug(LogEntry& entry, const std::string& source)
161 : LogEvent(entry, LogCategory::Debug, Messaging::toStrRef(source))
162 {
163 }
164};
165
166// Sugar-coat for adding basic type data to log entry.
167
170template <typename Undefined>
171LogEvent& operator<<(LogEvent& event, Undefined undefined)
172{
173 struct DefineOperatorForGivenType {} var = undefined;
174
175 return event;
176}
177
179inline LogEvent& operator<<(LogEvent& event, const Messaging::Char* cStr)
180{
181 event.message() += cStr;
182
183 return event;
184}
185
187inline LogEvent& operator<<(LogEvent& event, const std::string& str)
188{
189 event.message() += str;
190
191 return event;
192}
193
196{
197 Messaging::toStr(event.message(), strRef);
198
199 return event;
200}
201
203inline LogEvent& operator<<(LogEvent& event, Messaging::Char character)
204{
205 event.message() += character;
206
207 return event;
208}
209
212{
213 Messaging::toStr(event.message(), number);
214
215 return event;
216}
217
220{
221 Messaging::toStr(event.message(), number);
222
223 return event;
224}
225
228{
229 Messaging::toStr(event.message(), number);
230
231 return event;
232}
233
236{
237 Messaging::toStr(event.message(), number);
238
239 return event;
240}
241
244{
245 Messaging::toStr(event.message(), number);
246
247 return event;
248}
249
252{
253 Messaging::toStr(event.message(), number);
254
255 return event;
256}
257
260{
261 Messaging::toStr(event.message(), number);
262
263 return event;
264}
265
268{
269 Messaging::toStr(event.message(), number);
270
271 return event;
272}
273
275template <class Mantissa, class Exponent>
277{
278 toStr(event.message(), number);
279
280 return event;
281}
282
283// Logs timestamp.
285{
286 toStr(event.message(), timestamp);
287
288 return event;
289}
290
292inline LogEvent& operator<<(LogEvent& event, const Messaging::TimeSpan& timeSpan)
293{
294 toStr(event.message(), timeSpan);
295
296 return event;
297}
298
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:69
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:61
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:73
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:163
Provides a mutable log entry whose lifetime is controlled by its logger.
Definition Logger.h:158
std::string & message()
Informational message to be added to a log.
Definition LogEvents.h:55
~LogEvent()
Commits entry to the log.
const std::string & message() const
Informational message to be added to a log.
Definition LogEvents.h:61
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:450
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 &str, BookState::Enum bookState)
Appends a string representation of a book state.
std::ostream & operator<<(std::ostream &stream, const IssueArgs &args)
Classifies the purpose of an individual log entry.
Definition Logger.h:93
Enum
Available log entry categories.
Definition Logger.h:99
LogDebug(LogEntry &entry, const Messaging::Char *source)
Initializes event as debug information.
Definition LogEvents.h:148
LogDebug(LogEntry &entry, Messaging::StrRef source)
Initializes event as debug information.
Definition LogEvents.h:154
LogDebug(LogEntry &entry, const std::string &source)
Initializes event as debug information.
Definition LogEvents.h:160
LogError(LogEntry &entry, Messaging::StrRef source)
Initializes event as error.
Definition LogEvents.h:88
LogError(LogEntry &entry, const std::string &source)
Initializes event as error.
Definition LogEvents.h:94
LogError(LogEntry &entry, const Messaging::Char *source)
Initializes event as error.
Definition LogEvents.h:82
LogInfo(LogEntry &entry, Messaging::StrRef source)
Initializes event as information.
Definition LogEvents.h:132
LogInfo(LogEntry &entry, const std::string &source)
Initializes event as information.
Definition LogEvents.h:138
LogInfo(LogEntry &entry, const Messaging::Char *source)
Initializes event as information.
Definition LogEvents.h:126
LogWarning(LogEntry &entry, Messaging::StrRef source)
Initializes event as warning.
Definition LogEvents.h:110
LogWarning(LogEntry &entry, const std::string &source)
Initializes event as warning.
Definition LogEvents.h:116
LogWarning(LogEntry &entry, const Messaging::Char *source)
Initializes event as warning.
Definition LogEvents.h:104