OnixS C++ CME MDP Conflated UDP Handler 1.1.2
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{
41 LogEntry& entry_;
42 std::string& message_;
43
44 // Object copying is not assumed.
45
46 LogEvent(const LogEvent&);
47 LogEvent& operator =(const LogEvent&);
48
49public:
52 LogEntry& entry,
53 LogCategory::Enum category,
54 const StrRef& source)
55 : entry_(entry)
56 , message_(entry.message())
57 {
58 entry_.category(category);
59 entry_.source(source);
60 }
61
64 {
65 entry_.commit();
66 }
67
69 std::string& message()
70 {
71 return message_;
72 }
73
75 const std::string& message() const
76 {
77 return message_;
78 }
79};
80
81// A few descendants for a particular purposes.
82
85{
88 LogEntry& entry,
89 const Char* source)
90 : LogEvent(
91 entry,
92 LogCategory::Error,
93 toStrRef(source))
94 {
95 }
96
99 LogEntry& entry,
100 const StrRef& source)
101 : LogEvent(
102 entry,
103 LogCategory::Error,
104 source)
105 {
106 }
107
110 LogEntry& entry,
111 const std::string& source)
112 : LogEvent(
113 entry,
114 LogCategory::Error,
115 toStrRef(source))
116 {
117 }
118};
119
122{
125 LogEntry& entry,
126 const Char* source)
127 : LogEvent(
128 entry,
129 LogCategory::Warning,
130 toStrRef(source))
131 {
132 }
133
136 LogEntry& entry,
137 const StrRef& source)
138 : LogEvent(
139 entry,
140 LogCategory::Warning,
141 source)
142 {
143 }
144
147 LogEntry& entry,
148 const std::string& source)
149 : LogEvent(
150 entry,
151 LogCategory::Warning,
152 toStrRef(source))
153 {
154 }
155};
156
159{
162 LogEntry& entry,
163 const Char* source)
164 : LogEvent(
165 entry,
166 LogCategory::Info,
167 toStrRef(source))
168 {
169 }
170
173 LogEntry& entry,
174 const StrRef& source)
175 : LogEvent(
176 entry,
177 LogCategory::Info,
178 source)
179 {
180 }
181
184 LogEntry& entry,
185 const std::string& source)
186 : LogEvent(
187 entry,
188 LogCategory::Info,
189 toStrRef(source))
190 {
191 }
192};
193
196{
199 LogEntry& entry,
200 const Char* source)
201 : LogEvent(
202 entry,
203 LogCategory::Debug,
204 toStrRef(source))
205 {
206 }
207
210 LogEntry& entry,
211 const StrRef& source)
212 : LogEvent(
213 entry,
214 LogCategory::Debug,
215 source)
216 {
217 }
218
221 LogEntry& entry,
222 const std::string& source)
223 : LogEvent(
224 entry,
225 LogCategory::Debug,
226 toStrRef(source))
227 {
228 }
229};
230
231// Sugar-coat for adding basic type data to log entry.
232
235template
236<
237 typename Undefined
238>
240operator <<(
241 LogEvent& event,
242 Undefined undefined)
243{
244 struct
245 DefineOperatorForGivenType
246 {}
247 var = undefined;
248
249 return event;
250}
251
253inline
255operator <<(
256 LogEvent& event,
257 const Char* cStr)
258{
259 event.message() += cStr;
260
261 return event;
262}
263
265inline
267operator <<(
268 LogEvent& event,
269 const std::string& str)
270{
271 event.message() += str;
272
273 return event;
274}
275
277inline
279operator <<(
280 LogEvent& event,
281 const StrRef& strRef)
282{
283 toStr(
284 event.message(),
285 strRef);
286
287 return event;
288}
289
291inline
293operator <<(
294 LogEvent& event,
295 Char character)
296{
297 event.message() += character;
298
299 return event;
300}
301
303inline
305operator <<(
306 LogEvent& event,
307 Int8 number)
308{
309 toStr(
310 event.message(),
311 number);
312
313 return event;
314}
315
317inline
319operator <<(
320 LogEvent& event,
321 UInt8 number)
322{
323 toStr(
324 event.message(),
325 number);
326
327 return event;
328}
329
331inline
333operator <<(
334 LogEvent& event,
335 Int16 number)
336{
337 toStr(
338 event.message(),
339 number);
340
341 return event;
342}
343
345inline
347operator <<(
348 LogEvent& event,
349 UInt16 number)
350{
351 toStr(
352 event.message(),
353 number);
354
355 return event;
356}
357
359inline
361operator <<(
362 LogEvent& event,
363 Int32 number)
364{
365 toStr(
366 event.message(),
367 number);
368
369 return event;
370}
371
373inline
375operator <<(
376 LogEvent& event,
377 UInt32 number)
378{
379 toStr(
380 event.message(),
381 number);
382
383 return event;
384}
385
387inline
389operator <<(
390 LogEvent& event,
391 Int64 number)
392{
393 toStr(
394 event.message(),
395 number);
396
397 return event;
398}
399
401inline
403operator <<(
404 LogEvent& event,
405 UInt64 number)
406{
407 toStr(
408 event.message(),
409 number);
410
411 return event;
412}
413
415template
416<
417 class Mantissa,
418 class Exponent
419>
420inline
422operator <<(
423 LogEvent& event,
424 const
426 <
427 Mantissa,
428 Exponent
429 >& number)
430{
431 toStr(
432 event.message(),
433 number);
434
435 return event;
436}
437
438// Logs timestamp.
439inline
441operator <<(
442 LogEvent& event,
443 const Timestamp& timestamp)
444{
445 toStr(
446 event.message(),
447 timestamp);
448
449 return event;
450}
451
452// Logs time span.
453inline
455operator <<(
456 LogEvent& event,
457 const TimeSpan& timeSpan)
458{
459 toStr(
460 event.message(),
461 timeSpan);
462
463 return event;
464}
465
#define ONIXS_CONFLATEDUDP_LTWT_STRUCT
Definition Bootstrap.h:99
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition Bootstrap.h:95
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition Bootstrap.h:157
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition Bootstrap.h:153
Abstraction of log entry in logging services.
Definition Logger.h:142
std::string & message()
Informational message to be added to a log.
Definition LogEvents.h:69
~LogEvent()
Commits entry to the log.
Definition LogEvents.h:63
const std::string & message() const
Informational message to be added to a log.
Definition LogEvents.h:75
LogEvent(LogEntry &entry, LogCategory::Enum category, const StrRef &source)
Initializes event with LogEntry instance.
Definition LogEvents.h:51
Represents time point without time-zone information.
Definition Time.h:472
UInt64 UInt64
uInt64.
Definition Fields.h:265
ONIXS_CONFLATEDUDP_EXPORTED void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
Int32 Int32
int32.
Definition Fields.h:69
char Char
Character type alias.
Definition String.h:36
UInt32 UInt32
uInt32.
Definition Fields.h:261
StrRef toStrRef(const std::string &str)
Constructs StrRef instance over std::string content.
Definition String.h:174
Int16 Int16
int16.
Definition Fields.h:65
UInt16 UInt16
uInt16.
Definition Fields.h:257
Categories for information being logged.
Definition Logger.h:91
Enum
Categories for information being logged.
Definition Logger.h:97
LogDebug(LogEntry &entry, const StrRef &source)
Initializes event as debug information.
Definition LogEvents.h:209
LogDebug(LogEntry &entry, const Char *source)
Initializes event as debug information.
Definition LogEvents.h:198
LogDebug(LogEntry &entry, const std::string &source)
Initializes event as debug information.
Definition LogEvents.h:220
LogError(LogEntry &entry, const StrRef &source)
Initializes event as error.
Definition LogEvents.h:98
LogError(LogEntry &entry, const Char *source)
Initializes event as error.
Definition LogEvents.h:87
LogError(LogEntry &entry, const std::string &source)
Initializes event as error.
Definition LogEvents.h:109
LogInfo(LogEntry &entry, const std::string &source)
Initializes event as information.
Definition LogEvents.h:183
LogInfo(LogEntry &entry, const StrRef &source)
Initializes event as information.
Definition LogEvents.h:172
LogInfo(LogEntry &entry, const Char *source)
Initializes event as information.
Definition LogEvents.h:161
LogWarning(LogEntry &entry, const StrRef &source)
Initializes event as warning.
Definition LogEvents.h:135
LogWarning(LogEntry &entry, const std::string &source)
Initializes event as warning.
Definition LogEvents.h:146
LogWarning(LogEntry &entry, const Char *source)
Initializes event as warning.
Definition LogEvents.h:124