OnixS C++ CME Market Data Handler  5.7.0
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 
23 #include <OnixS/CME/MDH/String.h>
24 #include <OnixS/CME/MDH/Integral.h>
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_CMEMDH_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_CMEMDH_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.
161  traceFeeds(
162  bool status)
163  {
164  group_.
165  controlAssignment
166  (
167  "Trace Feeds",
168  traceFeeds_,
169  status
170  );
171 
172  return *this;
173  }
174 
175  /// Defines the way SBE messages are traced.
176  /// @note By default, messages are not traced.
177  MessageTracing::
178  Enum
179  traceMessages() const
180  {
181  return traceMessages_;
182  }
183 
184  /// Defines the way SBE messages are traced.
186  traceMessages(
187  MessageTracing::Enum tracing)
188  {
189  group_.
190  controlAssignment
191  (
192  "Trace Messages",
193  traceMessages_,
194  tracing
195  );
196 
197  return *this;
198  }
200  /// Indicates whether books are traced.
201  /// @note By default, books are not traced.
202  bool
203  traceBooks() const
204  {
205  return traceBooks_;
206  }
207 
208  /// Indicates whether books are traced.
210  traceBooks(
211  bool status)
212  {
213  group_.
214  controlAssignment
215  (
216  "TraceBooks",
217  traceBooks_,
218  status
219  );
220 
221  return *this;
222  }
223 
224  /// Re-initializes as a copy.
226  operator =(
227  const
228  DebugLoggingSettings& other)
229  {
230  group_.
231  controlChange
232  (
233  "Debug Logging Settings",
234  &DebugLoggingSettings::assignNoControl,
235  *this,
236  other
237  );
238 
239  return *this;
240  }
241 };
242 
243 #if !defined (ONIXS_CMEMDH_NO_DEPRECATED)
244 
245 typedef
248 
249 #endif // ONIXS_CMEMDH_NO_DEPRECATED
250 
251 /// Serializes Handler debug logging settings into a string.
252 ONIXS_CMEMDH_EXPORTED
253 void
254 toStr(
255  std::string&,
256  const DebugLoggingSettings&);
257 
258 /// Serializes Handler debug logging settings into a string.
259 inline
260 std::string
262  const
263  DebugLoggingSettings& settings)
264 {
265  std::string str;
266 
267  toStr(str, settings);
268 
269  return str;
270 }
271 
272 /// Provides default functionality
273 /// for the logging-related services.
275 {
276  /// Returns instance of the default logger.
277  static Logger& logger()
278  {
279  static NullLogger nullLogger;
280 
281  return nullLogger;
282  }
283 };
284 
285 /// The collection of settings affecting
286 /// use of logging subsystem by the Handler.
289  : public SettingGroup
290 {
291  friend
293  (
295  );
296 
297  Logger* logger_;
298 
299  DebugLoggingSettings debug_;
300 
301  const
302  SettingGroup&
303  group() const
304  {
305  return *this;
306  }
307 
308  void
309  assignNoControl(
310  const LoggingSettings& other)
311  {
312  logger_ =
313  other.logger_;
314 
315  debug_.
316  assignNoControl(
317  other.debug_);
318  }
319 
320 public:
321  /// Initializes the instance with the default values.
324  controller = NULL)
325  : SettingGroup(controller)
326  , logger_(&LoggingDefaults::logger())
327  , debug_(&group())
328  {
329  }
330 
331  /// Initializes as a copy of the other instance.
333  const LoggingSettings& other)
334  : SettingGroup()
335  , logger_(other.logger_)
336  , debug_(other.debug_)
337  {
338  }
339 
340  /// The Logger instance to be used by the
341  /// Handler while logging various events.
342  ///
343  /// No instance may be returned identifying
344  /// no logger is associated and thus nothing
345  /// is to be logged by the Handler.
346  Logger* logger() const
347  {
348  return
349  (
350  &LoggingDefaults::
351  logger() != logger_
352  ? logger_
353  : NULL
354  );
355  }
356 
357  /// The Logger instance to be used by the
358  /// Handler while logging various events.
359  ///
360  /// If no instance was assigned by the user,
361  /// the default logger is provided.
362  Logger& loggerOrDefault() const
363  {
364  return *logger_;
365  }
366 
367  /// Assigns the given logger to the Handler.
368  ///
369  /// Null instance tells the Handler to do not log
370  /// any data and thus reduces general processing time.
372  logger(
373  Logger* logger)
374  {
375  group().
376  controlAssignment
377  (
378  "Logger",
379  logger_,
380  logger
381  ? logger
382  : &LoggingDefaults::logger()
383  );
384 
385  return *this;
386  }
387 
388  /// The collection of settings
389  /// affecting debug-level logging.
390  ///
391  /// The Handler may log a lot of data at
392  /// debug level. The given collection allows
393  /// to filter debug information being logged.
394  const
396  debug() const
397  {
398  return debug_;
399  }
400 
401  /// The collection of settings
402  /// affecting debug-level logging.
403  ///
404  /// The Handler may log a lot of data at
405  /// debug level. The given collection allows
406  /// to filter debug information being logged.
408  debug()
409  {
410  return debug_;
411  }
413  /// Re-initializes the instance
414  /// as a copy of the other one.
416  operator =(
417  const LoggingSettings& other)
418  {
419  group().
420  controlChange
421  (
422  "Logging Settings",
423  &LoggingSettings::assignNoControl,
424  *this,
425  other
426  );
427 
428  return *this;
429  }
430 };
431 
432 /// Serializes Handler debug logging settings into a string.
433 ONIXS_CMEMDH_EXPORTED
434 void
435 toStr(
436  std::string&,
437  const LoggingSettings&);
438 
439 /// Serializes Handler debug logging settings into a string.
440 inline
441 std::string
443  const
444  LoggingSettings& settings)
445 {
446  std::string str;
447 
448  toStr(str, settings);
449 
450  return str;
451 }
452 
Defines how SBE messages are traced.
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:94
Handler&#39;s configuration settings.
UInt32 UInt32
uInt32.
Definition: Fields.h:247
Enum
Defines how SBE messages are traced.
ONIXS_CMEMDH_EXPORTED bool fromStr(MessageTracing::Enum &, const Char *, size_t)
Deserializes message tracing constant from a string.
Parameters affecting what&#39;s logged at a debug level.
Implements logging services to put data to nowhere.
Definition: NullLogger.h:28
char Char
Character type alias.
Definition: String.h:36
UInt32 Base
Integral type used as basement for constants.
Message tracing is disabled.
#define ONIXS_CMEMDH_LTWT_STRUCT
Definition: Bootstrap.h:98
static Logger & logger()
Returns instance of the default logger.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:152
std::string toStr(const LoggingSettings &settings)
Serializes Handler debug logging settings into a string.
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:124
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:106
Abstraction of logger.
Definition: Logger.h:179
DebugLoggingSettings HandlerDebugLoggingSettings
#define ONIXS_CMEMDH_EXPORTED_STRUCT
Definition: Bootstrap.h:58
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:156