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