OnixS C++ B3 Binary UMDF Market Data Handler  1.4.2
API documentation
LogSettings.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by ONIX SOLUTIONS LIMITED [ONIXS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
23 
24 #include <string>
25 
26 namespace OnixS
27 {
28  namespace B3
29  {
30  namespace MarketData
31  {
32  namespace UMDF
33  {
34 
35  /// Log level.
36  struct ONIXS_B3_UMDF_MD_API LogLevel
37  {
38  enum Enum
39  {
40  Disabled, ///< Disable logging
41  Fatal, ///< Fatal error, cannot continue.
42  Error, ///< System error, but we can go on.
43  Warning, ///< User or logic error, just say about it.
44  Info, ///< Information message.
45  Trace, ///< Used for tracing, usually including functions' names and args.
46  Debug, ///< Used for debugging.
47  };
48  };
49 
50  /// Returns string representation of ErrorCode value.
51  ONIXS_B3_UMDF_MD_API std::string enumToString (LogLevel::Enum);
52 
53  /// Logging options.
54  struct ONIXS_B3_UMDF_MD_API LogSettings
55  {
56  enum Enum
57  {
58  /// Trace to the log file.
59  TraceToFile = 0x01,
60 
61  /// Duplicate log messages to console.
62  /// @note Messages with LogLevel::Trace and LogLevel::Debug are not duplicated to console.
63  TraceToConsole = 0x02,
64 
65  /// Use asynchronous logging
66  Async = 0x4,
67 
68  /// if TraceToConsole is set, then direct output to stderr
69  ConsoleErr = 0x8,
70 
71  /// if TraceToConsole is set, then set up colored output mode
72  ConsoleColored = 0x10,
73 
74  /// if TraceToConsole is set, then append prefix to output
75  ConsoleShowPrefix = 0x20,
76 
77  /// Log binary data of received packets, applied only for Info log level and below.
78  LogPackets = 0x40,
79 
80  /// Log updated order book, applied only for Debug log level.
81  LogBooks = 0x80,
82 
83  /// Default log settings.
84  Default = TraceToFile | LogPackets | LogBooks
85  };
86  };
87 
88  /// Typed logical operator helper.
90  {
91  return LogSettings::Enum ( static_cast<int>(a) | static_cast<int>(b));
92  }
93 
94 
95  /// Log file read permissions.
96  struct ONIXS_B3_UMDF_MD_API LogFilePermission
97  {
98  enum Enum
99  {
100  /// read access only for owner of process
101  ReadOwnerOnly = 0x01,
102 
103  /// read access for all
104  ReadAll = 0x02,
105 
106  /// write access only for owner of process
107  WriteOwnerOnly = 0x04,
108 
109  /// write access for all
110  WriteAll = 0x08,
111 
112  /// Default value
113  Default = ReadAll | WriteOwnerOnly
114  };
115  };
116 
117  /// Typed logical operator helper.
119  {
120  return static_cast<LogFilePermission::Enum> (static_cast<int> (a) | static_cast<int> (b) );
121  }
122 
123  /// Logger-related settings
125  {
126  /// Constructor.
128  : logDirectory("logs")
129  , logFileNamePrefix("B3Umdf")
130  , logSettings(LogSettings::Default)
131  , logLevel(LogLevel::Info)
132  , logFilePermissions(LogFilePermission::Default)
133  {}
134 
135  /// Log files are stored in this directory.
136  std::string logDirectory;
137 
138  /// Template of log file name without extension.
139  std::string logFileNamePrefix;
140 
141  /// Combine LogSettings enum values to configure the logger.
143 
144  /// Log verbosity.
145  ///
146  /// @note The default value is LogLevel::Info
148 
149  /// Log file permissions.
150  ///
151  /// @note The default value is ReadAll | WriteOwnerOnly
153  };
154 
155  ONIXS_B3_UMDF_MD_API std::ostream& operator<<(std::ostream& stream, const LoggerSettings& settings);
156  }
157  }
158  }
159 }
LogLevel::Enum logLevel
Log verbosity.
Definition: LogSettings.h:147
LogSettings::Enum logSettings
Combine LogSettings enum values to configure the logger.
Definition: LogSettings.h:142
ONIXS_B3_UMDF_MD_API std::ostream & operator<<(std::ostream &stream, const LoggerSettings &settings)
User or logic error, just say about it.
Definition: LogSettings.h:43
LogSettings::Enum operator|(LogSettings::Enum a, LogSettings::Enum b)
Typed logical operator helper.
Definition: LogSettings.h:89
Fatal error, cannot continue.
Definition: LogSettings.h:41
Definition: Handler.h:31
LogFilePermission::Enum logFilePermissions
Log file permissions.
Definition: LogSettings.h:152
std::string logDirectory
Log files are stored in this directory.
Definition: LogSettings.h:136
Used for tracing, usually including functions&#39; names and args.
Definition: LogSettings.h:45
std::string logFileNamePrefix
Template of log file name without extension.
Definition: LogSettings.h:139
ONIXS_B3_UMDF_MD_API std::string enumToString(LogLevel::Enum)
Returns string representation of ErrorCode value.
System error, but we can go on.
Definition: LogSettings.h:42