OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
Logger.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/Integral.h>
24 #include <OnixS/CME/MDH/String.h>
25 
27 
28 /// Defines severity levels for log entries.
30 {
31  /// Enumeration base.
32  typedef UInt32 Base;
33 
34  /// Log alternates.
35  enum Enum
36  {
37  /// Only important information like
38  /// warnings and errors will be logged.
39  ///
40  /// Mode is not suitable for further log
41  /// replays, because no market data is stored.
42  Important = 10,
43 
44  /// Handler will log miscellaneous aspects
45  /// related with its execution like changes
46  /// in state, network data obtained, etc. All
47  /// critical important information like warnings
48  /// and errors will be logged as well.
49  ///
50  /// Most suitable mode to produce logs for further replay.
51  Regular = 50,
52 
53  /// In addition to the data logged in 'Regular'
54  /// mode, Handler will output additional information
55  /// like step-by-step changes into books, step-by-step
56  /// processing of received network packets.
57  Debug = 100
58  };
59 };
60 
61 /// Serializes log severity constant.
63 void toStr(std::string&, LogSeverity::Enum);
64 
65 /// Serializes log severity constant.
66 inline std::string toStr(LogSeverity::Enum mode)
67 {
68  std::string str;
69 
70  toStr(str, mode);
71 
72  return str;
73 }
74 
75 /// Deserializes log severity constant.
77 bool fromStr(LogSeverity::Enum&, const Char*, size_t);
78 
79 /// Categories for information being logged.
81 {
82  // Enumeration base.
83  typedef UInt32 Base;
84 
85  /// Categories for information being logged.
86  enum Enum
87  {
88  /// Log entry represents an error.
90 
91  /// Log entry represents a warning.
93 
94  /// Log entry represents informational message.
96 
97  /// Log entry represents debug information.
98  Debug
99  };
100 };
101 
102 /// Serializes log category constant.
104 void toStr(std::string&, LogCategory::Enum);
105 
106 /// Serializes log category constant.
107 inline std::string toStr(LogCategory::Enum mode)
108 {
109  std::string str;
110 
111  toStr(str, mode);
112 
113  return str;
114 }
115 
116 /// Deserializes log category constant.
118 bool fromStr(LogCategory::Enum&, const Char*, size_t);
119 
120 /// Abstraction of log entry in logging services.
122 {
123 public:
124  /// Specifies category of information being logged.
125  virtual void category(LogCategory::Enum) = 0;
126 
127  /// Specifies source of information being logged.
128  virtual void source(const StrRef&) = 0;
129 
130  /// Editable text to be a message of log entry.
131  virtual std::string& message() = 0;
132 
133  /// Commits entry into a log and releases the instance.
134  ///
135  /// Once given member is invoked, further invocation
136  /// of other members is not allowed as instance may be
137  /// disposed and thus do not exist anymore.
138  virtual void commit() = 0;
139 
140 protected:
141  /// Life-time is managed by Logger.
142  LogEntry() {}
143 
144  /// Life-time is managed by Logger.
145  virtual ~LogEntry() {}
146 
147 private:
148  // Object copying is not supposed.
149 
150  LogEntry(const LogEntry&);
151  LogEntry& operator=(const LogEntry&);
152 };
153 
154 /// Abstraction of logger.
156 {
157 public:
158  /// Finalizes the instance.
159  virtual ~Logger() {}
160 
161  /// Basic information on the implementation
162  /// of the logging services.
163  virtual void info(std::string&) = 0;
164 
165  /// Adds entry to the log.
166  ///
167  /// Actual content can be added through the
168  /// interface of LogEntry and LogEvent classes.
169  ///
170  /// @return Instance of LogEntry to build message
171  /// being added into the log or NULL if severity
172  /// of entry being added does not correspond to
173  /// logger's configuration.
174  virtual LogEntry* addEntry(LogSeverity::Enum) = 0;
175 
176 protected:
177  /// Only descendants are to be created.
178  Logger() {}
179 
180 private:
181  // Object copying is not supposed.
182 
183  Logger(const Logger&);
184  Logger& operator=(const Logger&);
185 };
186 
Log entry represents informational message.
Definition: Logger.h:95
UInt32 UInt32
uInt32.
Definition: Fields.h:192
virtual ~Logger()
Finalizes the instance.
Definition: Logger.h:159
Defines severity levels for log entries.
Definition: Logger.h:29
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
Abstraction of log entry in logging services.
Definition: Logger.h:121
Logger()
Only descendants are to be created.
Definition: Logger.h:178
char Char
Character type alias.
Definition: String.h:36
LogEntry()
Life-time is managed by Logger.
Definition: Logger.h:142
Log entry represents an error.
Definition: Logger.h:89
Provides efficient way of accessing text-based values without copying content of the text being refer...
Definition: String.h:41
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
std::string toStr(LogCategory::Enum mode)
Serializes log category constant.
Definition: Logger.h:107
Categories for information being logged.
Definition: Logger.h:80
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
Enum
Log alternates.
Definition: Logger.h:35
UInt32 Base
Enumeration base.
Definition: Logger.h:32
Abstraction of logger.
Definition: Logger.h:155
virtual ~LogEntry()
Life-time is managed by Logger.
Definition: Logger.h:145
Log entry represents a warning.
Definition: Logger.h:92
bool fromStr(LogCategory::Enum &, const Char *, size_t)
Deserializes log category constant.
Enum
Categories for information being logged.
Definition: Logger.h:86
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68