OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
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
27
29
50
53void toStr(std::string&, MessageTracing::Enum);
54
56inline std::string toStr(MessageTracing::Enum tracing)
57{
58 std::string str;
59
60 toStr(str, tracing);
61
62 return str;
63}
64
68
71{
72public:
74 DebugLoggingSettings(const SettingGroup* group = nullptr)
75 : group_(group ? *group : SettingGroup::null())
76 , traceFeeds_(false)
77 , traceMessages_(MessageTracing::Disabled)
78 , traceBooks_(false)
79 {
80 }
81
84 : group_(SettingGroup::null())
85 , traceFeeds_(other.traceFeeds_)
86 , traceMessages_(other.traceMessages_)
87 , traceBooks_(other.traceBooks_)
88 {
89 }
90
93
96 bool traceFeeds() const
97 {
98 return traceFeeds_;
99 }
100
105 {
106 group_.controlAssignment("Trace Feeds", traceFeeds_, status);
107
108 return *this;
109 }
110
114 {
115 return traceMessages_;
116 }
117
122 {
123 group_.controlAssignment("Trace Messages", traceMessages_, tracing);
124
125 return *this;
126 }
127
130 bool traceBooks() const
131 {
132 return traceBooks_;
133 }
134
139 {
140 group_.controlAssignment("TraceBooks", traceBooks_, status);
141
142 return *this;
143 }
144
149 {
150 group_.controlChange("Debug Logging Settings", &DebugLoggingSettings::assignNoControl, *this, other);
151
152 return *this;
153 }
154
155protected:
156 // To let assignment be controlled
157 // by the master container.
159
160 // Re-initializes the given instance
161 // as a copy of the other one without
162 // involving assignment control service.
164 {
165 traceFeeds_ = other.traceFeeds_;
166
167 traceMessages_ = other.traceMessages_;
168
169 traceBooks_ = other.traceBooks_;
170 }
171
172private:
173 const SettingGroup& group_;
174
175 bool traceFeeds_;
176 MessageTracing::Enum traceMessages_;
177 bool traceBooks_;
178};
179
180#if !defined(ONIXS_CMEMDH_NO_DEPRECATED)
181
182typedef DebugLoggingSettings HandlerDebugLoggingSettings;
183
184#endif // ONIXS_CMEMDH_NO_DEPRECATED
185
188void toStr(std::string&, const DebugLoggingSettings&);
189
191inline std::string toStr(const DebugLoggingSettings& settings)
192{
193 std::string str;
194
195 toStr(str, settings);
196
197 return str;
198}
199
203{
205 static Logger& logger();
206
207 static const char* fileName()
208 {
209 return "OnixS.CmeMdpPremiumCppHandlers.log";
210 }
211
212private:
213 static FileLoggerSettings createSettings()
214 {
215 FileLoggerSettings fileLoggerSettings;
216 fileLoggerSettings.filename(fileName());
217
218 return fileLoggerSettings;
219 }
220};
221
225{
226public:
229 : SettingGroup(controller)
230 , logger_(&LoggingDefaults::logger())
231 , debug_(&group())
232 {
233 }
234
237 : SettingGroup()
238 , logger_(other.logger_)
239 , debug_(other.debug_)
240 {
241 }
242
245 Logger* logger() const
246 {
247 return (&LoggingDefaults::logger() != logger_ ? logger_ : nullptr);
248 }
249
253 {
254 return *logger_;
255 }
256
263 {
264 group().controlAssignment("Logger", logger_, logger ? logger : &LoggingDefaults::logger());
265
266 return *this;
267 }
268
276 {
277 return debug_;
278 }
279
287 {
288 return debug_;
289 }
290
296 {
297 group().controlChange("Logging Settings", &LoggingSettings::assignNoControl, *this, other);
298
299 return *this;
300 }
301
302private:
304
305 Logger* logger_;
306
308
309 const SettingGroup& group() const
310 {
311 return *this;
312 }
313
314 void assignNoControl(const LoggingSettings& other)
315 {
316 logger_ = other.logger_;
317
318 debug_.assignNoControl(other.debug_);
319 }
320};
321
324void toStr(std::string&, const LoggingSettings&);
325
327inline std::string toStr(const LoggingSettings& settings)
328{
329 std::string str;
330
331 toStr(str, settings);
332
333 return str;
334}
335
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:69
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:61
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition Bootstrap.h:63
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:73
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:163
Parameters affecting what's logged at a debug level.
MessageTracing::Enum traceMessages() const
~DebugLoggingSettings()
Cleans everything up (if necessary).
DebugLoggingSettings(const SettingGroup *group=nullptr)
Initializes default settings.
DebugLoggingSettings & traceMessages(MessageTracing::Enum tracing)
DebugLoggingSettings(const DebugLoggingSettings &other)
Initializes as a copy.
void assignNoControl(const DebugLoggingSettings &other)
DebugLoggingSettings & operator=(const DebugLoggingSettings &other)
DebugLoggingSettings & traceFeeds(bool status)
DebugLoggingSettings & traceBooks(bool status)
Base parameters affecting synchronous logging services.
Definition FileLogger.h:37
const std::string & filename() const
Definition FileLogger.h:54
Defines the interface for creating and submitting log entries.
Definition Logger.h:198
LoggingSettings & logger(Logger *logger)
Selects the logger to be used by the Handler.
DebugLoggingSettings & debug()
LoggingSettings(const LoggingSettings &other)
Initializes as a copy of the other instance.
Logger * logger() const
Returns the custom logger selected for the Handler.
Logger & loggerOrDefault() const
Returns the effective logger selected for the Handler.
const DebugLoggingSettings & debug() const
LoggingSettings(SettingChangeController *controller=nullptr)
Initializes the instance with the default values.
LoggingSettings & operator=(const LoggingSettings &other)
Associates setting mutations with a change controller.
SettingGroup(SettingChangeController *controller=nullptr)
Creates a setting group that uses the specified controller.
void controlChange(const Messaging::Char *description, void(Changeable::*change)(), Changeable &changeable) const
Invokes a zero-argument member function as a guarded change.
void controlAssignment(const Messaging::Char *description, Assignee &assignee, Value value) const
Assigns a value while coordinating the change with the controller.
std::uint32_t UInt32
uInt32.
Definition Integral.h:35
char Char
Character type alias.
Definition String.h:30
void fromStr(NifList &, const std::string &, const std::string &=std::string("; ,"))
void toStr(std::string &str, BookState::Enum bookState)
Appends a string representation of a book state.
static Logger & logger()
Returns an instance of the default logger.
Defines how SBE messages are traced.
Enum
Defines how SBE messages are traced.
@ FixFormat
Messages are traced in FIX tag=value format.
@ Disabled
Message tracing is disabled.
Messaging::UInt32 Base
Integral type used as basement for constants.
Coordinates changes to settings that belong to a setting group.