ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
variables.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_alox of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_LOX_METAINFO
9#define HPP_ALIB_LOX_METAINFO 1
10#pragma once
11#include "alib/alox/alox.hpp"
12
16
17
18namespace alib::lox::textlogger {
19
20//==================================================================================================
21/// Definition of the main log-line format string for class \alib{lox;textlogger::TextLogger}
22/// and its derivates.
23/// This struct is used to define an external \ref alib_mod_config "configuration variable"
24/// named \ref alxcvALOX_LOGGERNAME_FORMAT.
25/// This variable can be accessed programatically
26/// with \alib{lox::textlogger;TextLogger::GetFormatMetaInfo} or by accessing the variable's value
27/// through the configuration object found in camp singleton #alib::ALOX.
28//==================================================================================================
30{
31 /// The line format specifies the (automated) log output that is prepended to each log line before
32 /// the log message itself. This format string can be changed after the creation
33 /// of a \ref TextLogger.
34 ///
35 /// The string supports replacement variables that begin with a <c>\%</c> character:
36 /// - \%SP: The full path of the source file
37 /// - \%Sp: The trimmed path of the source file
38 /// - \%SF: The caller's source file name
39 /// - \%Sf: The caller's source file name without extension
40 /// - \%SL: The line number in the source file
41 /// - \%SM: The method name
42 ///
43 /// - \%TD: The date the log call was invoked
44 /// - \%TT: Time of day the log call was invoked
45 /// - \%TC: Time elapsed since the Logger was created or its timer was reset
46 /// - \%TL: Time elapsed since the last log call
47 ///
48 /// - \%tN: Thread name
49 /// - \%tI: Thread ID
50 /// - \%V: The verbosity. This is replaced by the corresponding strings found in fields
51 /// #VerbosityError, #VerbosityWarning, #VerbosityInfo and #VerbosityVerbose.
52 /// - \%D: Log domain
53 /// - \%#: The log call counter (like a line counter, but counting multi lines as one)
54 /// - \%An: An auto-adjusted tabulator. This grows whenever it needs, but never shrinks. The
55 /// optional integer number n specifies how much extra space is added when tab is adjusted.
56 /// Setting this to a higher value avoids too many adjustments at the beginning of a log session.
57 /// - \%LG: The name of the \e Logger. This might be useful if multiple loggers write to the same
58 /// output stream (e.g., Console).
59 /// - \%LX: The name of the \e Lox.
60 /// - \%P: The name of the process / application.
61 ///
62 /// Resourced default is
63 /// \code "%Sp/%SF(%SL):%A5%SM() %A5[%TC +%TL][%tN]%V[%D]%A1(%#): " \endcode
64 ///
65 /// If debug logging as well as release logging has scope information disabled
66 /// (see \ref ALOX_DBG_LOG_CI and \ref ALOX_REL_LOG_CI), then it defaults to:
67 /// <c>"[%TC +%TL][%tN]%V[%D]%A1(%#): "</c>
68 ///
69 /// \note
70 /// The use of <c>%%TD</c> and <c>%%TT</c> may become problematic and ambiguous if the
71 /// system clock is changed during a software run. Especially for long-running background
72 /// software (daemons, servers, etc.), the software that uses \alox needs to provide
73 /// a strategy of synchronizing the clock with field
74 /// \alib{lox::textlogger;TextLogger::DateConverter}.<br>
75 /// For some explanation of the problem see details of namespace #alib::time.
77
78 /// The replacement for variable \c %%V in field #Format if \e Verbosity is \c Error.
79 /// Resourced as '[ERR]'.
81
82 /// The replacement for variable \c %%V in field #Format if \e Verbosity is \c Warning.
83 /// Resourced as '[WRN]'.
85
86 /// The replacement for variable \c %%V in field #Format if \e Verbosity is \c Info.
87 /// Resourced as ' '.
89
90 /// The replacement for variable \c %%V in field #Format if \e Verbosity is \c Verbose.
91 /// Resourced as to '[***]'.
93
94 /// Characters written after each <em>Log Statement</em>.
95 /// This may be used for example to reset colors and styles.
96 /// Note, that with multi-line <em>Log Statements</em>, the contents of this field is \b not
97 /// written at the end of each line, but only at the end of the last line.
98 /// To define characters that are written after each line of a multi-line
99 /// <em>Log Statement</em>, set field #MsgSuffix.
100 ///
101 /// Defaults to empty string.
103
104
105 /// Constructor taking an object pool which is passed to each string member.
106 /// @param pool The pool object of the \alib{config;Configuration}.
108 : Format (pool)
109 , VerbosityError (pool)
110 , VerbosityWarning (pool)
111 , VerbosityInfo (pool)
112 , VerbosityVerbose (pool)
113 , MsgSuffix (pool) {}
114}; // struct FormatMetaInfo
115
116//==================================================================================================
117/// Definition of date and time formats for class \alib{lox;textlogger::TextLogger}
118/// and its derivates.
119/// This struct is used to define an external \ref alib_mod_config "configuration variable"
120/// named \ref alxcvALOX_LOGGERNAME_FORMAT_DATE_TIME.
121/// This variable can be accessed programatically
122/// with \alib{lox::textlogger;TextLogger::GetFormatDate} or by accessing the variable's value
123/// through the configuration object found in camp singleton #alib::ALOX.
124//==================================================================================================
126{
127 /// Format string for the output of the log date. For more information, see
128 /// "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat().
130
131 /// Format string for the output of the time of day. For more information, see
132 /// "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat().
134
135 /// The word "Days" the out put of time elapsed (if longer than a day).
137
138 /// Constructor taking an object pool which is passed to each string member.
139 /// @param pool The pool object of the \alib{config;Configuration}.
141 : Date (pool)
142 , TimeOfDay (pool)
143 , ElapsedDays(pool) {}
144}; // struct DateFormat
145
146//==================================================================================================
147/// Definition of the formats of time differences for class
148/// \alib{lox;textlogger::TextLogger} and its derivates.
149/// This struct is used to define an external \ref alib_mod_config "configuration variable"
150/// named \ref alxcvALOX_LOGGERNAME_FORMAT_TIME_DIFF.
151/// This variable can be accessed programatically
152/// with \alib{lox::textlogger;TextLogger::GetFormatTimeDiff} or by accessing the variable's value
153/// through the configuration object found in camp singleton #alib::ALOX.
154//==================================================================================================
156{
157 /// Minimum time difference to log in nanoseconds. Below that #None is written.
158 int64_t Minimum;
159
160 /// Output for time difference if below reasonable (measurable) minimum defined in #Minimum.
162
163 /// Entity nanoseconds for time difference outputs below 1000 microsecond.
165
166 /// Entity microseconds for time difference outputs below 1000 microseconds.
168
169 /// Entity milliseconds for time difference outputs below 1000 milliseconds.
171
172 /// Format for time difference outputs between 10s and 99.9s.
174
175 /// Format for time difference outputs between 100s and 60 min.
177
178 /// Format for time difference outputs between 1h and 24h.
180
181 /// Format for time difference outputs of more than a day.
183
184 /// Constructor taking an object pool which is passed to each string member.
185 /// @param pool The pool object of the \alib{config;Configuration}.
187 : None (pool)
188 , Nanos (pool)
189 , Micros(pool)
190 , Millis(pool)
191 , Secs (pool)
192 , Mins (pool)
193 , Hours (pool)
194 , Days (pool) {}
195};
196
197//==================================================================================================
198/// Definition of the multi-line message mode for class \alib{lox;textlogger::TextLogger}
199/// and its derivates.
200/// This struct is used to define an external \ref alib_mod_config "configuration variable"
201/// named \ref alxcvALOX_LOGGERNAME_FORMAT_MULTILINE.
202/// This variable can be accessed programatically
203/// with \alib{lox::textlogger;TextLogger::GetFormatMultiLine} or by accessing the variable's value
204/// through the configuration object found in camp singleton #alib::ALOX.
205//==================================================================================================
207{
208 /// Determines if multi line messages should be split into different log lines. Possible
209 /// values are:
210 ///
211 /// - 0: No line split is performed, delimiters can be replaced by readable delimiters
212 /// (depending on setting of #Delimiter and #DelimiterReplacement).
213 ///
214 /// - 1: Each log line contains all meta-information
215 ///
216 /// - 2: Starting with second log line, meta-information is replaced by blanks (default)
217 ///
218 /// - 3: The headline #Headline is logged and all lines of the multi line
219 /// text are logged at position zero (without further meta-information)
220 ///
221 /// - 4: Just the multi line text is logged, starting at column zero (no meta-information
222 /// is logged)
223 ///
224 /// \note In modes 3 and 4, no ESC::EOMETA is included at the beginning of the message.
225 /// Loggers that need such info, have to implement method
226 /// \alib{lox::textlogger;TextLogger::notifyMultiLineOp}.
227 int Mode;
228
229 /// This is the string interpreted as line delimiter within log messages. If \e nulled, then
230 /// <c>'\\n'</c>, <c>'\\r'</c> or <c>'\\r\\n'</c> is recognized.<br>
231 /// Important: Can be set to an empty string, to stop any multi line processing of
232 /// \b %TextLogger, even the replacements of the delimiter character.
234
235 /// Headline for multi line messages (depending on #Mode) .
236 /// Defaults to "ALox: Multi line message follows: "
238
239 /// Prefix for multi line messages. This is also used if multi line messages logging is
240 /// switched off (MultiLineMsgMode == 0) but replacing of a set MultiLineDelimiter takes
241 /// place.
242 /// Defaults to ">> ".
244
245 /// Suffix for multi line messages. This is also used if multi line messages logging is
246 /// switched off (MultiLineMsgMode == 0) and replacing of a set #Delimiter
247 /// takes place.<br>
248 /// Note that at the end of the last line, in addition #Suffix is added.<br>
249 /// Defaults to "".
251
252 /// This is the readable (!) separator string, for logging out multi line messages into a
253 /// single line (#Mode==0).
254 /// Defaults to "\\r".
256
257 /// Constructor taking an object pool which is passed to each string member.
258 /// @param pool The pool object of the \alib{config;Configuration}.
260 : Delimiter (pool)
261 , Headline (pool)
262 , Prefix (pool)
263 , Suffix (pool)
264 , DelimiterReplacement(pool) {}
265
266};
267
268//==================================================================================================
269/// Definition of further format options for class \alib{lox;textlogger::TextLogger}
270/// and its derivates.
271/// This struct is used to define an external \ref alib_mod_config "configuration variable"
272/// named \ref alxcvALOX_LOGGERNAME_FORMAT_OTHER.
273/// This variable can be accessed programatically
274/// with \alib{lox::textlogger;TextLogger::GetFormatOther} or by accessing the variable's value
275/// through the configuration object found in camp singleton #alib::ALOX.
276//==================================================================================================
278{
279 /// Replacement string if no source info is available.
281
282 /// Replacement string if no source info is available.
284
285 /// The minimum digits to write for the log number (if used in format string).
287
288 /// Constructor taking an object pool which is passed to each string member.
289 /// @param pool The pool object of the \alib{config;Configuration}.
291 : NoSourceFileInfo(pool)
292 , NoMethodInfo (pool) {}
293}; // struct FormatOther
294
295
296//==================================================================================================
297/// Automatically detected field width and tab-stop positions for the meta-information part
298/// as well as the log message part, collected during the run of a software.
299/// This struct is used to define an external \ref alib_mod_config "configuration variable"
300/// named \ref alxcvALOX_LOGGERNAME_AUTO_SIZES.
301///
302/// This variable can be accessed programatically either with method
303/// \alib{lox::textlogger;TextLogger::GetAutoSizes} or by accessing the variable's value
304/// through the configuration object found in camp singleton #alib::ALOX.
305///
306/// For almost all use cases, field #Main will work as expected, because the meta-information
307/// of log lines usually do not change. In other words, if they get changed, it is a good idea
308/// to invoke \alib{strings::util;AutoSizes::Reset} on that field.
309///
310/// Field #LogMessage with built-in text loggers, is passed to field
311/// \alib{lang::format;FormatterPythonStyle::Sizes} and thus is used to organize tab-stops and
312/// field widths of the log messages itself.<br>
313/// The field may be reset manually after (or before) a coherent set of log messages have
314/// been (respectively are to be) written. Such "coherent set" is for example the output of
315/// tabular data. If this is not done, a next table containing different data, would not be
316/// printed with correct field sizes in case the automatic tab-stops.
317///
318/// Also, it might be reasonable to invoke \alib{strings::util::AutoSizes;Consolidate} one both
319/// objects from time to time, or in certain situations.
320///
321/// @see %Variable \ref alxcvALOX_LOGGERNAME_AUTO_SIZES.
322//==================================================================================================
324{
325 /// The instance used with the meta info format string.
327
328 /// An \b AutoSizes object which is used to format the log message itself.
329 /// \note With the use of class \alib{lox::textlogger;StandardConverter}, this
330 /// instance is passed to the internal instance(s) of the
331 /// \alib{lang::format;FormatterPythonStyle} used.
333}; // struct FormatAutoSizes
334
335//==================================================================================================
336/// A simple list of pairs of strings to search in log messages and their replacement value.
337/// This variable can be accessed programatically with
338/// \alib{lox::textlogger;TextLogger::GetReplacements} or by accessing the variable's value
339/// through the configuration object found in camp singleton #alib::ALOX.
340//==================================================================================================
342{
343 /// The list of pairs of replacement strings
344 std::vector<AStringPA, lang::StdContainerAllocator<AStringPA, PoolAllocator>> Pairs;
345
346 /// Constructor taking an object pool which is passed to the string vector.
347 /// @param pool The pool object of the \alib{config;Configuration}.
349 : Pairs(pool) {}
350};
351
352/// Parameters specific to colorful loggers. As of today, this simply has one attribute.
354{
355 /// Denotes the use of light vs dark colors. Used with colorful descendants of class
356 /// \alib{lox::textlogger;TextLogger}.
358 {
359 Auto, ///< Automatic
360 Never, ///< Never use light colors
361 Foreground, ///< Use light colors for foreground
362 Background ///< Use light colors for background
363 };
364
365 LightColorUsage LCU= LightColorUsage::Auto; ///< Denotes use of light or dark colors.
366 ///< Defaults to \e Auto.
367};
368
369
370} // namespace [alib::lox::textlogger]
371
372DOX_MARKER([DOX_CONFIG_DEFINETYPE1])
374DOX_MARKER([DOX_CONFIG_DEFINETYPE1])
375ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( alib::lox::textlogger::, FormatDateTime ,A_CHAR("ALOXFDT") )
376ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( alib::lox::textlogger::, FormatTimeDiff ,A_CHAR("ALOXFTD") )
377ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( alib::lox::textlogger::, FormatMultiLine ,A_CHAR("ALOXFML") )
378ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( alib::lox::textlogger::, FormatOther ,A_CHAR("ALOXFO" ) )
379ALIB_CONFIG_VARIABLE_DEFINE_TYPE ( alib::lox::textlogger::, FormatAutoSizes ,A_CHAR("ALOXAS" ) )
380ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR( alib::lox::textlogger::, Replacements ,A_CHAR("ALOXSR" ) )
381ALIB_CONFIG_VARIABLE_DEFINE_TYPE ( alib::lox::textlogger::, ColorfulLoggerParameters ,A_CHAR("ALOXCLP") )
382
383
384ALIB_ENUMS_ASSIGN_RECORD( alib::lox::textlogger::ColorfulLoggerParameters::LightColorUsage, alib::enums::ERSerializable )
385
386
387#endif // HPP_ALIB_LOX_METAINFO
388
#define ALIB_CONFIG_VARIABLE_DEFINE_TYPE_WITH_POOL_CONSTRUCTOR(Namespace, CPPName, CfgTypeString)
Definition vmeta.hpp:186
#define A_CHAR(STR)
#define ALIB_CONFIG_VARIABLE_DEFINE_TYPE(Namespace, CPPName, CfgTypeString)
Definition vmeta.hpp:173
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
Definition records.hpp:712
This namespaces defines class TextLogger and its helpers.
Definition loxpimpl.inl:41
Definition alib.cpp:69
Parameters specific to colorful loggers. As of today, this simply has one attribute.
AutoSizes Main
The instance used with the meta info format string.
AStringPA ElapsedDays
The word "Days" the out put of time elapsed (if longer than a day).
FormatOther(PoolAllocator &pool)
NAStringPA NoMethodInfo
Replacement string if no source info is available.
NAStringPA NoSourceFileInfo
Replacement string if no source info is available.
int LogNumberMinDigits
The minimum digits to write for the log number (if used in format string).
AStringPA Secs
Format for time difference outputs between 10s and 99.9s.
AStringPA Hours
Format for time difference outputs between 1h and 24h.
AStringPA None
Output for time difference if below reasonable (measurable) minimum defined in Minimum.
AStringPA Nanos
Entity nanoseconds for time difference outputs below 1000 microsecond.
AStringPA Mins
Format for time difference outputs between 100s and 60 min.
AStringPA Micros
Entity microseconds for time difference outputs below 1000 microseconds.
AStringPA Millis
Entity milliseconds for time difference outputs below 1000 milliseconds.
int64_t Minimum
Minimum time difference to log in nanoseconds. Below that None is written.
AStringPA Days
Format for time difference outputs of more than a day.
std::vector< AStringPA, lang::StdContainerAllocator< AStringPA, PoolAllocator > > Pairs
The list of pairs of replacement strings.
Replacements(PoolAllocator &pool)