OnixS C++ CME MDP Conflated UDP Handler  1.1.2
API documentation
LoggingSettings.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 
25 
28 
30 
31 /// Defines how SBE messages are traced.
33 {
34  /// Integral type used as basement for constants.
35  typedef UInt32 Base;
36 
37  /// Defines how SBE messages are traced.
38  enum Enum
39  {
40  /// Message tracing is disabled.
42 
43  /// Messages are traced using SBE naming from
44  /// coding templates for fields and their values.
46 
47  /// Messages are traced in FIX tag=value format.
48  FixFormat
49  };
50 };
51 
52 /// Serializes message tracing constant into a string.
53 ONIXS_CONFLATEDUDP_EXPORTED
54 void
55 toStr(
56  std::string&,
58 
59 /// Serializes message tracing constant into a string.
60 inline
61 std::string
63  MessageTracing::Enum tracing)
64 {
65  std::string str;
66 
67  toStr(str, tracing);
68 
69  return str;
70 }
71 
72 /// Deserializes message tracing constant from a string.
73 ONIXS_CONFLATEDUDP_EXPORTED
74 bool
75 fromStr(
77  const Char*,
78  size_t);
79 
80 /// Parameters affecting what's logged at a debug level.
83 {
84  const SettingGroup& group_;
85 
86  bool traceFeeds_;
87  MessageTracing::Enum traceMessages_;
88  bool traceBooks_;
89 
90 protected:
91  // To let assignment be controlled
92  // by the master container.
93  friend
95  (
97  );
98 
99  // Re-initializes the given instance
100  // as a copy of the other one without
101  // involving assignment control service.
102  void
103  assignNoControl(
104  const
105  DebugLoggingSettings& other)
106  {
107  traceFeeds_ =
108  other.traceFeeds_;
109 
110  traceMessages_ =
111  other.traceMessages_;
112 
113  traceBooks_ =
114  other.traceBooks_;
115  }
116 
117 public:
118  /// Initializes default settings.
120  const SettingGroup* group = NULL)
121  : group_(
122  group
123  ? *group
124  : SettingGroup::null())
125  , traceFeeds_(false)
126  , traceMessages_(
127  MessageTracing::Disabled)
128  , traceBooks_(false)
129  {
130  }
131 
132  /// Initializes as a copy.
134  const DebugLoggingSettings& other)
135  : group_(
136  SettingGroup::null())
137  , traceFeeds_(
138  other.traceFeeds_)
139  , traceMessages_(
140  other.traceMessages_)
141  , traceBooks_(
142  other.traceBooks_)
143  {
144  }
145 
146  /// Cleans everything up (if necessary).
148  {
149  }
151  /// Defines whether feeds are to be traced.
152  /// @note By default, feeds are not traced.
153  bool
154  traceFeeds() const
155  {
156  return traceFeeds_;
157  }
158 
159  /// Defines whether feeds are to be traced.
160  void
161  traceFeeds(
162  bool status)
163  {
164  group_.
165  controlAssignment
166  (
167  "Trace Feeds",
168  traceFeeds_,
169  status
170  );
171  }
172 
173  /// Defines the way SBE messages are traced.
174  /// @note By default, messages are not traced.
176  Enum
177  traceMessages() const
178  {
179  return traceMessages_;
180  }
181 
182  /// Defines the way SBE messages are traced.
183  void
184  traceMessages(
185  MessageTracing::Enum tracing)
186  {
187  group_.
188  controlAssignment
189  (
190  "Trace Messages",
191  traceMessages_,
192  tracing
193  );
194  }
196  /// Indicates whether books are traced.
197  /// @note By default, books are not traced.
198  bool
199  traceBooks() const
200  {
201  return traceBooks_;
202  }
203 
204  /// Indicates whether books are traced.
205  void
206  traceBooks(
207  bool status)
208  {
209  group_.
210  controlAssignment
211  (
212  "TraceBooks",
213  traceBooks_,
214  status
215  );
216  }
217 
218  /// Re-initializes as a copy.
220  operator =(
221  const
222  DebugLoggingSettings& other)
223  {
224  group_.
225  controlAssignment
226  (
227  "Debug Logging Settings",
228  &DebugLoggingSettings::assignNoControl,
229  *this,
230  other
231  );
232 
233  return *this;
234  }
235 };
236 
237 #if !defined (ONIXS_CONFLATEDUDP_NO_DEPRECATED)
238 
239 typedef
242 
243 #endif // ONIXS_CONFLATEDUDP_NO_DEPRECATED
244 
245 /// Serializes Handler debug logging settings into a string.
246 ONIXS_CONFLATEDUDP_EXPORTED
247 void
248 toStr(
249  std::string&,
250  const DebugLoggingSettings&);
251 
252 /// Serializes Handler debug logging settings into a string.
253 inline
254 std::string
256  const
257  DebugLoggingSettings& settings)
258 {
259  std::string str;
260 
261  toStr(str, settings);
262 
263  return str;
264 }
265 
266 /// Provides default functionality
267 /// for the logging-related services.
269 {
270  /// Returns instance of the default logger.
271  static Logger& logger()
272  {
273  static NullLogger nullLogger;
274 
275  return nullLogger;
276  }
277 };
278 
279 /// The collection of settings affecting
280 /// use of logging subsystem by the Handler.
283  : public SettingGroup
284 {
285  friend
287  (
289  );
290 
291  Logger* logger_;
292 
293  DebugLoggingSettings debug_;
294 
295  const
296  SettingGroup&
297  group() const
298  {
299  return *this;
300  }
301 
302  void
303  assignNoControl(
304  const LoggingSettings& other)
305  {
306  logger_ =
307  other.logger_;
308 
309  debug_.
310  assignNoControl(
311  other.debug_);
312  }
313 
314 public:
315  /// Initializes the instance with the default values.
318  controller = NULL)
319  : SettingGroup(controller)
320  , logger_(&LoggingDefaults::logger())
321  , debug_(&group())
322  {
323  }
324 
325  /// Initializes as a copy of the other instance.
327  const LoggingSettings& other)
328  : SettingGroup()
329  , logger_(other.logger_)
330  , debug_(other.debug_)
331  {
332  }
333 
334  /// The Logger instance to be used by the
335  /// Handler while logging various events.
336  ///
337  /// No instance may be returned identifying
338  /// no logger is associated and thus nothing
339  /// is to be logged by the Handler.
340  Logger* logger() const
341  {
342  return
343  (
344  &LoggingDefaults::
345  logger() != logger_
346  ? logger_
347  : NULL
348  );
349  }
350 
351  /// The Logger instance to be used by the
352  /// Handler while logging various events.
353  ///
354  /// If no instance was assigned by the user,
355  /// the default logger is provided.
356  Logger& loggerOrDefault() const
357  {
358  return *logger_;
359  }
360 
361  /// Assigns the given logger to the Handler.
362  ///
363  /// Null instance tells the Handler to do not log
364  /// any data and thus reduces general processing time.
365  void
366  logger(
367  Logger* logger)
368  {
369  group().
370  controlAssignment
371  (
372  "Logger",
373  logger_,
374  logger
375  ? logger
376  : &LoggingDefaults::logger()
377  );
378  }
379 
380  /// The collection of settings
381  /// affecting debug-level logging.
382  ///
383  /// The Handler may log a lot of data at
384  /// debug level. The given collection allows
385  /// to filter debug information being logged.
386  const
388  debug() const
389  {
390  return debug_;
391  }
392 
393  /// The collection of settings
394  /// affecting debug-level logging.
395  ///
396  /// The Handler may log a lot of data at
397  /// debug level. The given collection allows
398  /// to filter debug information being logged.
400  debug()
401  {
402  return debug_;
403  }
405  /// Re-initializes the instance
406  /// as a copy of the other one.
408  operator =(
409  const LoggingSettings& other)
410  {
411  group().
412  controlAssignment
413  (
414  "Logging Settings",
415  &LoggingSettings::assignNoControl,
416  *this,
417  other
418  );
419 
420  return *this;
421  }
422 };
423 
424 /// Serializes Handler debug logging settings into a string.
425 ONIXS_CONFLATEDUDP_EXPORTED
426 void
427 toStr(
428  std::string&,
429  const LoggingSettings&);
430 
431 /// Serializes Handler debug logging settings into a string.
432 inline
433 std::string
435  const
436  LoggingSettings& settings)
437 {
438  std::string str;
439 
440  toStr(str, settings);
441 
442  return str;
443 }
444 
static Logger & logger()
Returns instance of the default logger.
Enum
Defines how SBE messages are traced.
UInt32 Base
Integral type used as basement for constants.
Handler's configuration settings.
UInt32 UInt32
uInt32.
Definition: Fields.h:261
#define ONIXS_CONFLATEDUDP_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:107
char Char
Character type alias.
Definition: String.h:36
Parameters affecting what's logged at a debug level.
#define ONIXS_CONFLATEDUDP_LTWT_STRUCT
Definition: Bootstrap.h:99
ONIXS_CONFLATEDUDP_EXPORTED bool fromStr(MessageTracing::Enum &, const Char *, size_t)
Deserializes message tracing constant from a string.
#define ONIXS_CONFLATEDUDP_EXPORTED_STRUCT
Definition: Bootstrap.h:59
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:123
Implements logging services to put data to nowhere.
Definition: NullLogger.h:28
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition: Bootstrap.h:157
std::string toStr(const LoggingSettings &settings)
Serializes Handler debug logging settings into a string.
DebugLoggingSettings HandlerDebugLoggingSettings
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition: Bootstrap.h:95
Abstraction of logger.
Definition: Logger.h:179
Defines how SBE messages are traced.
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition: Bootstrap.h:153