109 lines
14 KiB
HTML
109 lines
14 KiB
HTML
<!-- HTML header for doxygen 1.8.11-->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.11"/>
|
|
<title>OnixS C++ CME Market Data Handler: Logging Services</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="onixs-doxygen.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript">
|
|
$(window).scroll(function() {
|
|
if ($(this).scrollTop() > 1)
|
|
{
|
|
$('header').addClass("sticky");
|
|
}
|
|
else
|
|
{
|
|
$('header').removeClass("sticky");
|
|
}
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><a href="http://www.onixs.biz"><img alt="Logo" src="onixs.svg"/></a></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">OnixS C++ CME Market Data Handler
|
|
 <span id="projectnumber">4.8.0.10</span>
|
|
</div>
|
|
<div id="projectbrief">API documentation</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</header>
|
|
<div id="wrapper">
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.11 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Home</span></a></li>
|
|
<li class="current"><a href="modules.html"><span>Contents</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Logging Services<div class="ingroups"><a class="el" href="group__getting-started.html">Getting Started</a> | <a class="el" href="group__what-is-new.html">What's New and Important Changes</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<h1><a class="anchor" id="logger-abstraction"></a>
|
|
Logger Abstraction</h1>
|
|
<p>The logging services have been advanced in the SDK starting with this major release. Now it exposes abstraction of logging services defining the way for users to bring custom solutions more suitable for their purposes.</p>
|
|
<p>Logger abstraction is based on two primary classes:</p>
|
|
<ul>
|
|
<li>The <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1Logger.html" title="Abstraction of logger. ">OnixS::CME::MDH::Logger</a> which serves as a primary logging instrument, and</li>
|
|
<li>The <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html" title="Abstraction of log entry in logging services. ">OnixS::CME::MDH::LogEntry</a> which represents an abstraction of a logged entry.</li>
|
|
</ul>
|
|
<p>The <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1Logger.html" title="Abstraction of logger. ">OnixS::CME::MDH::Logger</a> defines an interface for adding entries to the logger. The <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html" title="Abstraction of log entry in logging services. ">OnixS::CME::MDH::LogEntry</a> in its turn defines an interface of the entry being added to a log.</p>
|
|
<p>The SDK contains a few utility classes like <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEvent.html">OnixS::CME::MDH::LogEvent</a> and its descendants to improve the experience with using logging services.</p>
|
|
<p>A typical use-case for the logger inside the Handler looks like following:</p>
|
|
<div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespaceOnixS_1_1CME_1_1MDH.html">OnixS::CME::MDH</a>;</div><div class="line"></div><div class="line"><span class="keywordflow">if</span> (<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html">LogEntry</a>* entry =</div><div class="line"> logger.addEntry(<a class="code" href="structOnixS_1_1CME_1_1MDH_1_1LogSeverity.html#a8150b7776c2a1749101acf22e868d091a903ac0aebd967dd74743cfaca8dc138e">LogSeverity::Important</a>))</div><div class="line">{</div><div class="line"> <a class="code" href="structOnixS_1_1CME_1_1MDH_1_1LogWarning.html">LogWarning</a> warning(*entry, warningSource);</div><div class="line"></div><div class="line"> <span class="keyword">static_cast<</span><a class="code" href="classOnixS_1_1CME_1_1MDH_1_1LogEvent.html">LogEvent</a>&<span class="keyword">></span>(warning) << warningDescription;</div><div class="line">}</div></div><!-- fragment --><p>Adding a new entry into a log is done by the OnixS::CME::MD3::Logger::addEntry member. It returns instance of OnixS::CME::MDH::Entry which should be used to put information to be logged.</p>
|
|
<p>An important aspect of Logger abstraction is the fact Logger may return NULL instance of <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html" title="Abstraction of log entry in logging services. ">OnixS::CME::MDH::LogEntry</a>. That may happen if the information, which is added to a log, has lower severity than a logger configured with it. For example, an implementation may log only important events and thus regular and debug information is ignored. Therefore, when a caller of the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1Logger.html#a80a7b622a5f4ad4d7c9ecca969c858c4">OnixS::CME::MDH::Logger::addEntry</a> supplies a lower severity level, the member returns a NULL instance.</p>
|
|
<p>A valid (non-NULL) instance of the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html" title="Abstraction of log entry in logging services. ">OnixS::CME::MDH::LogEntry</a> class it can be filled with any information. Once the entry is set up, information in it must be committed to the log by invoking the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1LogEntry.html#abd1bf75022f544db14cfd8f7153a5d30">OnixS::CME::MDH::LogEntry::commit</a> member.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>An instance of <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1Logger.html" title="Abstraction of logger. ">OnixS::CME::MDH::Logger</a> successor can be bound to multiple instances of OnixS:CME::MDH::Handler. Therefore, successors of the Logger abstraction must take into consideration the fact the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1Logger.html#a80a7b622a5f4ad4d7c9ecca969c858c4">OnixS::CME::MDH::Logger::addEntry</a> member can be invoked simultaneously.</dd></dl>
|
|
<dl class="section warning"><dt>Warning</dt><dd>It's up to the implementation to allow allocation of the new entries while another entry is in the process of fulfilling with data to be logged. However, the common rule while using a logger is to avoid adding multiple entries at the same time as other implementations may not allow that.</dd>
|
|
<dd>
|
|
Logging issues should not affect market data processing and thus should be exposed through own way. For example, the <a class="el" href="classOnixS_1_1CME_1_1MDH_1_1FileLogger.html">OnixS::CME::MDH::FileLogger</a> can be associated with an instance of the <a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FileLoggerListener.html" title="Collection of events raised by FileLogger during its life time. ">OnixS::CME::MDH::FileLoggerListener</a> class upon the instance construction. In case of failure like the inability to log an event into a file, an issue is raised and delivered through the <a class="el" href="structOnixS_1_1CME_1_1MDH_1_1FileLoggerListener.html#af3e3f6d17ee39e10816baf5dcec8eab4">OnixS::CME::MDH::FileLoggerListener::onFileLoggerIssue</a> member.</dd></dl>
|
|
<h1><a class="anchor" id="logger-implementations"></a>
|
|
Ready-to-use Logger Implementations</h1>
|
|
<p>The SDK comes with a few ready-to-use implementations of the Logger abstractions allowing the users to build their solutions quickly:</p>
|
|
<table class="doxtable">
|
|
<tr>
|
|
<th>Logger Implementation </th><th>Description </th></tr>
|
|
<tr>
|
|
<td>OnixS::CME:MDH::FileLogger </td><td>Implements logging services over text-based files. Logged data is stored into files which may be limited by size. Once volume reaches its limit, Logger detaches logged data, backs it up and starts a new volume. </td></tr>
|
|
<tr>
|
|
<td>OnixS::CME:MDH::NullLogger </td><td>Logs nothings. The Handler suppresses logging at all, if the instance of given class is bound to it. </td></tr>
|
|
</table>
|
|
<h1><a class="anchor" id="bind-logger-to-handler"></a>
|
|
Binding Logger to the Handler</h1>
|
|
<p>The Handler logs important aspects of its execution with the help of Logger abstraction explained above. Logging includes network data received and processed by the Handler, states of books and, of course, errors occurred at execution time.</p>
|
|
<p>The following example demonstrates how to configure and bind file-based logger to the Handler:</p>
|
|
<div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespaceOnixS_1_1CME_1_1MDH.html">OnixS::CME::MDH</a>;</div><div class="line"></div><div class="line"><span class="comment">// Implementing logger listener to get notified on </span></div><div class="line"><span class="comment">// issues which are not raised through other ways. </span></div><div class="line"></div><div class="line"><span class="keyword">struct </span>FileLoggerIssueTracer</div><div class="line">: <a class="code" href="structOnixS_1_1CME_1_1MDH_1_1FileLoggerListener.html">FileLoggerListener</a></div><div class="line">{</div><div class="line"> <span class="comment">// Member is invoked when file logger experience </span></div><div class="line"> <span class="comment">// issue solely beloning to logging subsystem. </span></div><div class="line"> <span class="keywordtype">void</span></div><div class="line"> onFileLoggerIssue(</div><div class="line"> <span class="keyword">const</span> <a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FileLogger.html">FileLogger</a>& logger,</div><div class="line"> <span class="keyword">const</span> <a class="code" href="namespaceOnixS_1_1CME_1_1MDH.html#a7942e32f6409fbd1fd347a8c23ef725e">Char</a>* issue)</div><div class="line"> {</div><div class="line"> std::cout</div><div class="line"> << <span class="stringliteral">"ALERT!!! "</span></div><div class="line"> <span class="stringliteral">"Issue occurred while logging data. "</span> </div><div class="line"> << issue</div><div class="line"> << std::endl;</div><div class="line"> }</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">// Later, in code..</span></div><div class="line"></div><div class="line"><a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerSettings.html">HandlerSettings</a> handlerSettings;</div><div class="line"></div><div class="line">handlerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerSettings.html#a24903c4532def98d24d336351ef3bcbc">channel</a>(310);</div><div class="line">handlerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerSettings.html#a403bf7d770e77c7c0084c5391dbce957">feeds</a>().<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FeedSettings.html#ad103c61bd73b750ab7f9e9ab7f8884ae">connectivityConfigurationFile</a>(<span class="stringliteral">"config.xml"</span>);</div><div class="line"></div><div class="line">handlerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerSettings.html#a35a9d00d39b544359d45f8d6aadd9ecd">debugLogging</a>().<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerDebugLoggingSettings.html#a2f9aecd4f17c83351004ff81e421570e">traceMessages</a>(<a class="code" href="structOnixS_1_1CME_1_1MDH_1_1MessageTracing.html#a8150b7776c2a1749101acf22e868d091a43732d5078986cac8230345bd13d28b7">MessageTracing::SbeFormat</a>);</div><div class="line"></div><div class="line"><a class="code" href="classOnixS_1_1CME_1_1MDH_1_1Handler.html">Handler</a> handler(handlerSettings);</div><div class="line"></div><div class="line"><a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FileLoggerSettings.html">FileLoggerSettings</a> loggerSettings;</div><div class="line"></div><div class="line">loggerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FileLoggerSettings.html#af89fbda9897f8c41faf1862e1790e3f2">filename</a>(<a class="code" href="namespaceOnixS_1_1CME_1_1MDH.html#a194c6b882145a3993041bd0db14eb0f4">makeLogFilename</a>(handlerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1HandlerSettings.html#a24903c4532def98d24d336351ef3bcbc">channel</a>()));</div><div class="line">loggerSettings.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FileLoggerSettings.html#ac13c631743548845547017e0e6f177ac">severityLevel</a>(<a class="code" href="structOnixS_1_1CME_1_1MDH_1_1LogSeverity.html#a8150b7776c2a1749101acf22e868d091ac909e86054cb6ad83c22bfc2b3e6e5b8">LogSeverity::Debug</a>);</div><div class="line"></div><div class="line">FileLoggerIssueTracer loggerTracer;</div><div class="line"></div><div class="line"><a class="code" href="classOnixS_1_1CME_1_1MDH_1_1FileLogger.html">FileLogger</a> logger(loggerSettings, &loggerTracer);</div><div class="line"></div><div class="line">handler.<a class="code" href="classOnixS_1_1CME_1_1MDH_1_1Handler.html#aeeb037536de9886000fe0b965ab09d5f">bindLogger</a>(logger);</div></div><!-- fragment --> </div><!-- contents -->
|
|
<!-- HTML footer for doxygen 1.8.11-->
|
|
<!-- start footer part -->
|
|
<footer>
|
|
<hr class="footer"/>
|
|
<address class="footer">
|
|
<small>© <a href="http://www.onixs.biz">Onix Solutions [On<span class="corporate-orange">i</span>x<span class="corporate-orange">S</span>]</a>. All rights reserved.</small>
|
|
</address>
|
|
</footer>
|
|
</div> <!-- wrapper -->
|
|
</body>
|
|
</html>
|