OnixS C++ CME Streamlined Market Data Handler  1.1.0.5
API documentation
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 
27 
29 
30 /// Base parameters affecting synchronous logging services.
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.
43  : filename_()
44  , fileSizeLimit_(2145386496)
45  , severity_(LogSeverity::Regular)
46  , watch_(&UtcWatch::service())
47  {
48  }
49 
50  /// Cleans everything up.
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'.
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.
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.
100  {
101  severity_ = value;
102  }
103 
104  /// Watch service used by logger while
105  /// assigning timestamps to log entries.
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_CMESTREAMLINEDMDH_EXPORTED
121 std::string
123 
125 
126 /// Collection of events raised by FileLogger during its life time.
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
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.
147 {
148  // File logger machinery implementation.
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
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(
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 
UInt64 UInt64
uInt64.
Definition: Fields.h:187
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS_DECL(typeName)
Definition: Bootstrap.h:54
LogSeverity::Enum severityLevel() const
Definition: FileLogger.h:92
ONIXS_CMESTREAMLINEDMDH_EXPORTED std::string makeLogFilename(UInt32)
Makes filename for log file for the given channel.
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:172
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition: Bootstrap.h:110
char Char
Character type alias.
Definition: String.h:36
Abstraction of log entry in logging services.
Definition: Logger.h:141
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS
Definition: Bootstrap.h:62
Abstract watch service.
Definition: Time.h:868
Collection of events raised by FileLogger during its life time.
Definition: FileLogger.h:127
void severityLevel(LogSeverity::Enum value)
Definition: FileLogger.h:99
virtual void onFileLoggerIssue(const FileLogger &, const Char *)
Definition: FileLogger.h:136
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:122
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_STRUCT
Definition: Bootstrap.h:66
const std::string & filename() const
Definition: FileLogger.h:58
void filename(const std::string &value)
Definition: FileLogger.h:66
Base parameters affecting synchronous logging services.
Definition: FileLogger.h:31
FileLoggerSettings()
Initializes parameters with default values.
Definition: FileLogger.h:42
Defines severity levels for log entries.
Definition: Logger.h:29
void fileSizeLimit(UInt64 value)
Sets logFileSizeLimit.
Definition: FileLogger.h:83
Abstraction of logger.
Definition: Logger.h:179
UInt32 UInt32
uInt32.
Definition: Fields.h:183
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168