OnixS C++ CME Market Data Handler
4.8.0.10
API documentation
Home
Contents
Namespaces
Classes
Files
File List
File Members
include
OnixS
CME
MDH
FileLogger.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
#include <
OnixS/CME/MDH/Logger.h
>
26
#include <
OnixS/CME/MDH/Time.h
>
27
28
ONIXS_CMEMDH_NAMESPACE_BEGIN
29
30
/// Base parameters affecting synchronous logging services.
31
ONIXS_CMEMDH_LTWT_CLASS
FileLoggerSettings
32
{
33
std::string filename_;
34
UInt64
fileSizeLimit_;
35
36
LogSeverity::Enum
severity_;
37
38
WatchService
* watch_;
39
40
public
:
41
/// Initializes parameters with default values.
42
FileLoggerSettings
()
43
: filename_()
44
, fileSizeLimit_(2145386496)
45
, severity_(
LogSeverity
::Regular)
46
, watch_(&
UtcWatch
::service())
47
{
48
}
49
50
/// Cleans everything up.
51
~FileLoggerSettings
()
52
{
53
}
54
55
/// Log file name.
56
///
57
/// Ignored if logging is disabled.
58
const
std::string&
filename
()
const
59
{
60
return
filename_;
61
}
62
63
/// Updates log file name.
64
///
65
/// Ignored if logging is disabled.
66
void
filename
(
const
std::string& value)
67
{
68
filename_ = value;
69
}
70
71
/// Log file size limit (in bytes).
72
///
73
/// Handler detaches logged data into separate
74
/// file upon reaching given size limit.
75
///
76
/// @note Default value is '2145386496'.
77
UInt64
fileSizeLimit
()
const
78
{
79
return
fileSizeLimit_;
80
}
81
82
/// Sets logFileSizeLimit. @see logFileSizeLimit.
83
void
fileSizeLimit
(
UInt64
value)
84
{
85
fileSizeLimit_ = value;
86
}
87
88
/// Specifies whether the logger should output events
89
/// and which of events should be put into the log.
90
///
91
/// @note The default value is LogEntrySeverity::Regular.
92
LogSeverity::Enum
severityLevel
()
const
93
{
94
return
severity_;
95
}
96
97
/// Specifies whether logger should output its events
98
/// and which of events should be put into the log.
99
void
severityLevel
(
LogSeverity::Enum
value)
100
{
101
severity_ = value;
102
}
103
104
/// Watch service used by logger while
105
/// assigning timestamps to log entries.
106
WatchService
&
watch
()
const
107
{
108
return
*watch_;
109
}
110
111
/// Watch service used by logger while
112
/// assigning timestamps to log entries.
113
void
watch
(
WatchService
& watch)
114
{
115
watch_ = &watch;
116
}
117
};
118
119
/// Makes filename for log file for the given channel.
120
ONIXS_CMEMDH_EXPORTED
121
std::string
122
makeLogFilename
(
UInt32
);
123
124
ONIXS_CMEMDH_EXPORTED_CLASS_DECL
(
FileLogger
);
125
126
/// Collection of events raised by FileLogger during its life time.
127
ONIXS_CMEMDH_EXPORTED_STRUCT
FileLoggerListener
128
{
129
/// Invoked by FileLogger in case of issue.
130
///
131
/// FileLogger may experience issues like inability to
132
/// add a new entry due to insufficient disk space. Once
133
/// occurred, issue is reported through given callback.
134
virtual
135
void
136
onFileLoggerIssue
(
137
const
FileLogger
&,
138
const
Char
*)
139
{
140
}
141
};
142
143
/// Implements logging services to put logged data into a
144
/// regular file. Provides additional facilities like splitting
145
/// logged data into chunks not exceeding specified size limit.
146
ONIXS_CMEMDH_EXPORTED_CLASS
FileLogger
:
public
Logger
147
{
148
// File logger machinery implementation.
149
ONIXS_CMEMDH_LTWT_CLASS_DECL
(Workhorse);
150
Workhorse* workhorse_;
151
152
public
:
153
/// Initializes logger according to given settings.
154
FileLogger
(
155
const
FileLoggerSettings
&,
156
FileLoggerListener
* = NULL);
157
158
/// Disposes logging machinery.
159
~
FileLogger
();
160
161
/// Configuration of given logger instance.
162
const
163
FileLoggerSettings
&
164
settings()
const
;
165
166
/// Adds a new entry into the log.
167
///
168
/// Returns instance for further fulfill or NULL if
169
/// given severity is lower than defined by settings
170
/// at the moment of instance construction.
171
LogEntry
*
172
addEntry(
173
LogSeverity::Enum
);
174
175
/// Rolls over current log and starts recording a new chunk.
176
///
177
/// Detached data is stored into a file whose name is
178
/// suffixed with a timestamp taken at the moment of detach.
179
/// Timestamp is taken using watch service associated with
180
/// the logger using its settings.
181
///
182
/// @return Name of file containing detached data.
183
std::string rollover();
184
};
185
186
ONIXS_CMEMDH_NAMESPACE_END
OnixS::CME::MDH::FileLoggerListener
Collection of events raised by FileLogger during its life time.
Definition:
FileLogger.h:127
ONIXS_CMEMDH_LTWT_CLASS
#define ONIXS_CMEMDH_LTWT_CLASS
Definition:
Bootstrap.h:110
OnixS::CME::MDH::FileLoggerListener::onFileLoggerIssue
virtual void onFileLoggerIssue(const FileLogger &, const Char *)
Definition:
FileLogger.h:136
OnixS::CME::MDH::UInt32
UInt32 UInt32
uInt32.
Definition:
Fields.h:189
OnixS::CME::MDH::FileLoggerSettings
Base parameters affecting synchronous logging services.
Definition:
FileLogger.h:31
Time.h
OnixS::CME::MDH::LogSeverity
Defines severity levels for log entries.
Definition:
Logger.h:29
OnixS::CME::MDH::FileLoggerSettings::FileLoggerSettings
FileLoggerSettings()
Initializes parameters with default values.
Definition:
FileLogger.h:42
ONIXS_CMEMDH_EXPORTED_CLASS_DECL
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition:
Bootstrap.h:54
OnixS::CME::MDH::WatchService
Abstract watch service.
Definition:
Time.h:841
OnixS::CME::MDH::LogEntry
Abstraction of log entry in logging services.
Definition:
Logger.h:141
OnixS::CME::MDH::Char
char Char
Character type alias.
Definition:
String.h:36
OnixS::CME::MDH::FileLoggerSettings::filename
const std::string & filename() const
Definition:
FileLogger.h:58
OnixS::CME::MDH::FileLoggerSettings::watch
WatchService & watch() const
Definition:
FileLogger.h:106
OnixS::CME::MDH::UInt64
UInt64 UInt64
uInt64.
Definition:
Fields.h:193
ONIXS_CMEMDH_EXPORTED_CLASS
#define ONIXS_CMEMDH_EXPORTED_CLASS
Definition:
Bootstrap.h:62
OnixS::CME::MDH::UtcWatch
Definition:
Time.h:866
Integral.h
ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition:
Bootstrap.h:168
OnixS::CME::MDH::FileLoggerSettings::severityLevel
LogSeverity::Enum severityLevel() const
Definition:
FileLogger.h:92
ONIXS_CMEMDH_LTWT_CLASS_DECL
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition:
Bootstrap.h:122
OnixS::CME::MDH::LogSeverity::Enum
Enum
Log alternates.
Definition:
Logger.h:35
Logger.h
OnixS::CME::MDH::FileLoggerSettings::severityLevel
void severityLevel(LogSeverity::Enum value)
Definition:
FileLogger.h:99
OnixS::CME::MDH::makeLogFilename
ONIXS_CMEMDH_EXPORTED std::string makeLogFilename(UInt32)
Makes filename for log file for the given channel.
OnixS::CME::MDH::Logger
Abstraction of logger.
Definition:
Logger.h:179
OnixS::CME::MDH::FileLoggerSettings::~FileLoggerSettings
~FileLoggerSettings()
Cleans everything up.
Definition:
FileLogger.h:51
OnixS::CME::MDH::FileLoggerSettings::watch
void watch(WatchService &watch)
Definition:
FileLogger.h:113
ONIXS_CMEMDH_EXPORTED_STRUCT
#define ONIXS_CMEMDH_EXPORTED_STRUCT
Definition:
Bootstrap.h:66
OnixS::CME::MDH::FileLoggerSettings::filename
void filename(const std::string &value)
Definition:
FileLogger.h:66
OnixS::CME::MDH::FileLoggerSettings::fileSizeLimit
void fileSizeLimit(UInt64 value)
Sets logFileSizeLimit.
Definition:
FileLogger.h:83
String.h
OnixS::CME::MDH::FileLoggerSettings::fileSizeLimit
UInt64 fileSizeLimit() const
Definition:
FileLogger.h:77
OnixS::CME::MDH::FileLogger
Definition:
FileLogger.h:146
ONIXS_CMEMDH_NAMESPACE_END
#define ONIXS_CMEMDH_NAMESPACE_END
Definition:
Bootstrap.h:172