OnixS C++ CME MDP Premium Market Data Handler 5.9.0
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
26#include <OnixS/CME/MDH/Time.h>
27
29
31
40{
41public:
43 LogEvent(LogEntry& entry, LogCategory::Enum category, const StrRef& source)
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 Char* source)
86 : LogEvent(entry, LogCategory::Error, toStrRef(source))
87 {
88 }
89
91 LogError(LogEntry& entry, const StrRef& source)
92 : LogEvent(entry, LogCategory::Error, source)
93 {
94 }
95
97 LogError(LogEntry& entry, const std::string& source)
98 : LogEvent(entry, LogCategory::Error, toStrRef(source))
99 {
100 }
101};
102
105{
107 LogWarning(LogEntry& entry, const Char* source)
108 : LogEvent(entry, LogCategory::Warning, toStrRef(source))
109 {
110 }
111
113 LogWarning(LogEntry& entry, const StrRef& source)
114 : LogEvent(entry, LogCategory::Warning, source)
115 {
116 }
117
119 LogWarning(LogEntry& entry, const std::string& source)
120 : LogEvent(entry, LogCategory::Warning, toStrRef(source))
121 {
122 }
123};
124
127{
129 LogInfo(LogEntry& entry, const Char* source)
130 : LogEvent(entry, LogCategory::Info, toStrRef(source))
131 {
132 }
133
135 LogInfo(LogEntry& entry, const StrRef& source)
136 : LogEvent(entry, LogCategory::Info, source)
137 {
138 }
139
141 LogInfo(LogEntry& entry, const std::string& source)
142 : LogEvent(entry, LogCategory::Info, toStrRef(source))
143 {
144 }
145};
146
149{
151 LogDebug(LogEntry& entry, const Char* source)
152 : LogEvent(entry, LogCategory::Debug, toStrRef(source))
153 {
154 }
155
157 LogDebug(LogEntry& entry, const StrRef& source)
158 : LogEvent(entry, LogCategory::Debug, source)
159 {
160 }
161
163 LogDebug(LogEntry& entry, const std::string& source)
164 : LogEvent(entry, LogCategory::Debug, 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 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
200inline LogEvent& operator<<(LogEvent& event, const StrRef& strRef)
201{
202 toStr(event.message(), strRef);
203
204 return event;
205}
206
208inline LogEvent& operator<<(LogEvent& event, Char character)
209{
210 event.message() += character;
211
212 return event;
213}
214
216inline LogEvent& operator<<(LogEvent& event, Int8 number)
217{
218 toStr(event.message(), number);
219
220 return event;
221}
222
224inline LogEvent& operator<<(LogEvent& event, UInt8 number)
225{
226 toStr(event.message(), number);
227
228 return event;
229}
230
232inline LogEvent& operator<<(LogEvent& event, Int16 number)
233{
234 toStr(event.message(), number);
235
236 return event;
237}
238
240inline LogEvent& operator<<(LogEvent& event, UInt16 number)
241{
242 toStr(event.message(), number);
243
244 return event;
245}
246
248inline LogEvent& operator<<(LogEvent& event, Int32 number)
249{
250 toStr(event.message(), number);
251
252 return event;
253}
254
256inline LogEvent& operator<<(LogEvent& event, UInt32 number)
257{
258 toStr(event.message(), number);
259
260 return event;
261}
262
264inline LogEvent& operator<<(LogEvent& event, Int64 number)
265{
266 toStr(event.message(), number);
267
268 return event;
269}
270
272inline LogEvent& operator<<(LogEvent& event, UInt64 number)
273{
274 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.
289inline LogEvent& operator<<(LogEvent& event, const Timestamp& timestamp)
290{
291 toStr(event.message(), timestamp);
292
293 return event;
294}
295
296// Logs time span.
297inline LogEvent& operator<<(LogEvent& event, const TimeSpan& timeSpan)
298{
299 toStr(event.message(), timeSpan);
300
301 return event;
302}
303
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
Represents real number with constant exponent.
Definition Decimal.h:38
Abstraction of log entry in logging services.
Definition Logger.h:122
By default, logging machinery provides access to the entry with ability to store arbitrary text.
Definition LogEvents.h:40
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, const StrRef &source)
Initializes event with LogEntry instance.
Definition LogEvents.h:43
Provides efficient way of accessing text-based values without copying content of the text being refer...
Definition String.h:42
Represents time interval.
Definition Time.h:105
Represents time point without time-zone information.
Definition Time.h:388
Int8 Int8
int8.
Definition Fields.h:63
UInt64 UInt64
uInt64.
Definition Fields.h:205
Int32 Int32
int32.
Definition Fields.h:60
char Char
Character type alias.
Definition String.h:36
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
UInt32 UInt32
uInt32.
Definition Fields.h:202
StrRef toStrRef(const std::string &str)
Constructs StrRef instance over std::string content.
Definition String.h:155
Int16 Int16
int16.
Definition Fields.h:57
UInt8 UInt8
uInt8.
Definition Fields.h:208
UInt16 UInt16
uInt16.
Definition Fields.h:199
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 StrRef &source)
Initializes event as debug information.
Definition LogEvents.h:157
LogDebug(LogEntry &entry, const Char *source)
Initializes event as debug information.
Definition LogEvents.h:151
LogDebug(LogEntry &entry, const std::string &source)
Initializes event as debug information.
Definition LogEvents.h:163
LogError(LogEntry &entry, const StrRef &source)
Initializes event as error.
Definition LogEvents.h:91
LogError(LogEntry &entry, const Char *source)
Initializes event as error.
Definition LogEvents.h:85
LogError(LogEntry &entry, const std::string &source)
Initializes event as error.
Definition LogEvents.h:97
LogInfo(LogEntry &entry, const std::string &source)
Initializes event as information.
Definition LogEvents.h:141
LogInfo(LogEntry &entry, const StrRef &source)
Initializes event as information.
Definition LogEvents.h:135
LogInfo(LogEntry &entry, const Char *source)
Initializes event as information.
Definition LogEvents.h:129
LogWarning(LogEntry &entry, const 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 Char *source)
Initializes event as warning.
Definition LogEvents.h:107