ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alox_init.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4/// With supporting legacy or module builds, .mpp-files are either recognized by the build-system
5/// as C++20 Module interface files, or are included by the
6/// #"alib_manual_modules_impludes;import/include headers".
7///
8/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
9/// Published under #"mainpage_license".
10//==================================================================================================
11ALIB_EXPORT namespace alib { namespace lox {
12
13//==================================================================================================
14/// This enum is used in \alox to control the "verbosity" or "verboseness" of the log output.
15/// The values herein - apart from special value 'Off' - are sorted in the following order
16/// - Verbose (highest level)
17/// - Info
18/// - Warning
19/// - Error (lowest level).
20///
21/// A value of this set is provided to \alox in two different ways:
22/// First, all methods of class #"alib::lox::Lox;Lox" that execute a log operation
23/// assign a value of this enum to the <em>Log Statement</em>. Secondly, the overloaded methods
24/// #"Lox::SetVerbosity(detail::Logger*)", are defining the 'accepted'
25/// <em>minimal Verbosity</em> for a pair of <em><Logger/%Log Domain></em>.
26///
27/// \alox, when executing a statement, checks both values against each other.
28/// A <em>Log Statement</em> is executed, when the <em><Logger/%Log Domain></em> setting is set
29/// to the same or a 'higher level'. For example, if a <em><Logger/%Log Domain></em> setting is
30/// \b %Warning, then <em>Log Statements</em> with associated \e %Verbosity \b %Warning and
31/// \b %Error are executed and those with \b %Info and \b %Verbose are suppressed.
32///
33/// If special value \b %Off is used with #"Lox::SetVerbosity(detail::Logger*);Lox::SetVerbosity", all logging is switched off
34/// for this pair of <em><Logger/%Log Domain></em>.
35///
36/// Some of the <em>Log Statements</em> accept the parameter directly (e.g. #"Lox::Entry",
37/// #"Lox::Once(const NString&, Verbosity, const Box&, const String&, Scope, int);Lox::Once", and
38/// #"Lox::If(bool, const NString&, Verbosity, BoxedObjects&& ...);Lox::If"), while others
39/// inherently use the right value as their method name suggests (e.g.
40/// #"Lox::Error",
41/// #"Lox::Warning",
42/// #"Lox::Info",
43/// #"Lox::Verbose" and
44/// #"Lox::Assert").
45/// The latter group of methods do not support parameter \b %Off.
46///
47/// If special value \b %Off is used with those <em>Log Statements</em>, that allow to specify the
48/// \e %Verbosity as a parameter, the <em>Log Statement</em> is never executed This is useful if the
49/// parameter is determined at run-time, depending on the state of an application.
50//==================================================================================================
51enum class Verbosity : uint8_t
52{
53 /// Statements with this value associated are never logged (useful if \e %Verbosity is
54 /// evaluated at run-time). <em>%Log Domains</em> with this setting do not execute any
55 /// <em>Log Statement</em>.
57
58 /// A \e Verbosity for error messages.
59 /// It is suppressed only if a <em>%Log Domain</em>'s setting is \b %Off.
61
62 /// A \e Verbosity for warning messages, hence things that might lead to errors or are not
63 /// welcome for other reasons, but maybe are not errors.<br>
64 /// Logged if a <em>%Log Domain</em> is set to \b %Warning, \b %Info or \b %Verbose.
66
67 /// The standard \e Verbosity for normal log output statements.
68 /// Logged if a <em>%Log Domain</em> is set to \b %Info or \b %Verbose.
70
71 /// The 'highest' level of \e %Verbosity.
72 /// Statements with this value associated are logged only if a <em>%Log Domain</em> is set to
73 /// \b %Verbose as well.
75};
76
77
78//==================================================================================================
79/// These are definitions that are used as a parameter to certain \alox methods to denote
80/// the \e Scope of a setting. \e Scopes are dependent of the programming language
81/// and hence differ slightly from each other in the different versions of \alox.
82///
83/// This enumeration is an #"ArithmeticalTraits;ALib arithmetical enum". However,
84/// the addition of values is only allowed with the last element, \b Path. By adding integer
85/// values, the Nth parent directory of a source file's location are addressed. As an example,
86/// invocations like this are used to select the source directory two levels above the source
87/// code file for a prefix scope:
88///
89/// lox->SetPrefix( #"> ", Scope::Path + 2 );
90///
91/// \note
92/// \alox for C++ implements scope mechanisms using scope information generated by the
93/// preprocessor.
94/// By default, debug logging supports such 'caller information', while release logging
95/// does not.<br>
96/// Therefore, in release-logging, the use of \e Scopes 'Path', 'Filename' and
97/// 'Method' will just default to an empty scope and therefore the all reflect the same,
98/// shared scope, which is not very helpful. Therefore, for standard release logging,
99/// the use of the scope mechanisms should be avoided, unless scope information is
100/// explicitly enabled.<br>
101/// For more information on how to change the defaults, see documentation of preprocessor
102/// configuration macros #"ALOX_DBG_LOG_CI" and #"ALOX_REL_LOG_CI".
103///
104/// For more information on \e Scopes consult the #"alib_mod_alox".
105//==================================================================================================
106enum class Scope
107{
108 /// Denotes the global (singleton) scope.
110
111 /// Denotes the actual thread as the scope. When used with <em>Scope Domains</em>,
112 /// 'inner' scopes can be defined optionally by multiple definitions.
114
115 /// Denotes the actual source file as the scope.
117
118 /// Denotes the actual method as the scope.
120
121 /// Denotes the actual thread as the scope. When used with <em>Scope Domains</em>,
122 /// 'inner' scopes can be defined optionally by multiple definitions.
124
125 /// Denotes the actual source path as the scope. By adding positive integral values
126 /// to this element (the enum type is an #"ArithmeticalTraits;ALib arithmetical enum"),
127 /// 'outer' \e Scopes of this scope level itself can be defined using parent directories
128 /// of the path.
130};
131
132//==================================================================================================
133/// This class defines "escape sequences" that influence the formatting of log output.
134/// Specific implementations of class
135/// #"alib::lox::detail::Logger;Logger"
136/// have to convert or interpret this classes definitions of escape sequences
137/// when processing log data. If no formatting of the output is supported by a specific Logger
138/// implementation, such logger should filter and discard escape sequences defined here.
139///
140/// The sequences are similar to ANSI Escape sequences and logger classes that
141/// log to 'VT100' compatible terminals will simply convert them.
142///
143/// The name of the class was intentionally chosen to be short, because the escape codes
144/// defined with this class will be concatenated to log strings like that:
145///
146/// \snippet "ut_alox_dox.cpp" DOX_ALOX_ESC
147///
148/// \note
149/// With the introduction of own, \alox specific escape codes, software that uses ALox becomes
150/// independent of any underlying, platform-specific sequences. For example, \alox is not relying
151/// on ANSI color codes, which are not supported by colorful Windows consoles. Instead, on each
152/// platform, dedicated Loggers will perform the translation of \alox codes to platform-specific
153/// ones.
154//==================================================================================================
155class ESC
156{
157 public:
158 static constexpr character RED [4]{ A_CHAR("\033c0") }; ///< Select red color for foreground.
159 static constexpr character GREEN [4]{ A_CHAR("\033c1") }; ///< Select green color for foreground.
160 static constexpr character YELLOW [4]{ A_CHAR("\033c2") }; ///< Select yellow color for foreground.
161 static constexpr character BLUE [4]{ A_CHAR("\033c3") }; ///< Select blue color for foreground.
162 static constexpr character MAGENTA [4]{ A_CHAR("\033c4") }; ///< Select magenta color for foreground.
163 static constexpr character CYAN [4]{ A_CHAR("\033c5") }; ///< Select cyan color for foreground.
164 static constexpr character BLACK [4]{ A_CHAR("\033c6") }; ///< Select black color for foreground.
165 static constexpr character WHITE [4]{ A_CHAR("\033c7") }; ///< Select white color for foreground.
166 static constexpr character GRAY [4]{ A_CHAR("\033c8") }; ///< Select gray color for foreground.
167 static constexpr character FG_RESET [4]{ A_CHAR("\033c9") }; ///< Select std color for foreground.
168
169 static constexpr character BG_RED [4]{ A_CHAR("\033C0") }; ///< Select red color for background.
170 static constexpr character BG_GREEN [4]{ A_CHAR("\033C1") }; ///< Select green color for background.
171 static constexpr character BG_YELLOW [4]{ A_CHAR("\033C2") }; ///< Select yellow color for background.
172 static constexpr character BG_BLUE [4]{ A_CHAR("\033C3") }; ///< Select blue color for background.
173 static constexpr character BG_MAGENTA [4]{ A_CHAR("\033C4") }; ///< Select blue color for background.
174 static constexpr character BG_CYAN [4]{ A_CHAR("\033C5") }; ///< Select blue color for background.
175 static constexpr character BG_BLACK [4]{ A_CHAR("\033C6") }; ///< Select red color for background.
176 static constexpr character BG_WHITE [4]{ A_CHAR("\033C7") }; ///< Select blue color for background.
177 static constexpr character BG_GRAY [4]{ A_CHAR("\033C8") }; ///< Select gray color for background.
178 static constexpr character BG_RESET [4]{ A_CHAR("\033C9") }; ///< Select std color for background.
179
180 static constexpr character BOLD [4]{ A_CHAR("\033sB") }; ///< Select bold font style.
181 static constexpr character ITALICS [4]{ A_CHAR("\033sI") }; ///< Select italics font style.
182 static constexpr character STYLE_RESET[4]{ A_CHAR("\033sr") }; ///< Select standard font style.
183 static constexpr character RESET [4]{ A_CHAR("\033sa") }; ///< Reset color and style.
184
185 static constexpr character URL_START [4]{ A_CHAR("\033lS") }; ///< Mark the start of an URL.
186 static constexpr character URL_END [4]{ A_CHAR("\033lE") }; ///< Mark the end of an URL.
187 static constexpr character TAB [4]{ A_CHAR("\033t0") }; ///< Go to next tab. Usually, text loggers will increase the tab position automatically.
188
189 static constexpr character EOMETA [4]{ A_CHAR("\033A0") }; ///< End of meta-information in log string
190
191 /// Replaces ESC codes in a string reversely to "ESC::XXX".
192 /// @param target The string to replace in.
193 /// @param startIdx The index to start searching for ESC codes.
195 static void ReplaceToReadable( AString& target, integer startIdx );
196}; // class ESC
197
198
199/// Denotes flags used with methods #"Lox::GetState;*" and #"Lox::State;*" to select
200/// different parts of the state receive.
201enum class StateInfo
202{
203 NONE = 0, ///< No state
204 Basic = 1 << 0, ///< Name and number of log calls
205 Version = 1 << 1, ///< Library Version and thread safeness
206 Loggers = 1 << 2, ///< Loggers
207
208 Domains = 1 << 3, ///< Log domains currently registered
209 InternalDomains = 1 << 4, ///< Internal domains
210 ScopeDomains = 1 << 5, ///< Scope domains
211 DSR = 1 << 6, ///< Domain substitution rules
212 PrefixLogables = 1 << 7, ///< Prefix logables
213 Once = 1 << 8, ///< Log once counters
214 LogData = 1 << 9, ///< Log data objects
215 ThreadMappings = 1 << 10, ///< Named threads
216
217 SPTR = 1 << 20, ///< Source path trim rules
218 CompilationFlags = 1 << 21, ///< \alib/\alox compilation flags
219
220 All = ~0L, ///< All flags set.
221};
222
223
224} // namespace alib[::lox]
225
226
227/// Type alias in namespace \b alib.
229
230/// Type alias in namespace \b alib.
232
233/// Type alias in namespace \b alib.
235
236} // namespace [alib]
237
238
241
242
246
247
#define ALIB_DLL
Definition alib.inl:573
#define A_CHAR(STR)
Definition alib.inl:1325
#define ALIB_EXPORT
Definition alib.inl:562
#define ALIB_BOXING_VTABLE_DECLARE(TMapped, Identifier)
static constexpr character BG_GRAY[4]
Select gray color for background.
static constexpr character BOLD[4]
Select bold font style.
static constexpr character BG_WHITE[4]
Select blue color for background.
static constexpr character BG_RESET[4]
Select std color for background.
static constexpr character GREEN[4]
Select green color for foreground.
static constexpr character TAB[4]
Go to next tab. Usually, text loggers will increase the tab position automatically.
static constexpr character EOMETA[4]
End of meta-information in log string.
static constexpr character BG_MAGENTA[4]
Select blue color for background.
static constexpr character URL_START[4]
Mark the start of an URL.
static constexpr character BG_BLUE[4]
Select blue color for background.
static void ReplaceToReadable(AString &target, integer startIdx)
Definition aloxinit.cpp:48
static constexpr character GRAY[4]
Select gray color for foreground.
static constexpr character STYLE_RESET[4]
Select standard font style.
static constexpr character MAGENTA[4]
Select magenta color for foreground.
static constexpr character ITALICS[4]
Select italics font style.
static constexpr character CYAN[4]
Select cyan color for foreground.
static constexpr character FG_RESET[4]
Select std color for foreground.
static constexpr character BG_RED[4]
Select red color for background.
static constexpr character BG_BLACK[4]
Select red color for background.
static constexpr character URL_END[4]
Mark the end of an URL.
static constexpr character RESET[4]
Reset color and style.
static constexpr character BG_YELLOW[4]
Select yellow color for background.
static constexpr character BLACK[4]
Select black color for foreground.
static constexpr character BG_GREEN[4]
Select green color for background.
static constexpr character BG_CYAN[4]
Select blue color for background.
static constexpr character YELLOW[4]
Select yellow color for foreground.
static constexpr character WHITE[4]
Select white color for foreground.
static constexpr character RED[4]
Select red color for foreground.
static constexpr character BLUE[4]
Select blue color for foreground.
#define ALIB_ENUMS_MAKE_ARITHMETICAL(TEnum)
#define ALIB_ENUMS_ASSIGN_RECORD(TEnum, TRecord)
@ Filename
Denotes the actual source file as the scope.
@ Method
Denotes the actual method as the scope.
@ Global
Denotes the global (singleton) scope.
@ ScopeDomains
Scope domains.
@ CompilationFlags
ALib/ALox compilation flags
@ DSR
Domain substitution rules.
@ InternalDomains
Internal domains.
@ Version
Library Version and thread safeness.
@ PrefixLogables
Prefix logables.
@ Domains
Log domains currently registered.
@ LogData
Log data objects.
@ Basic
Name and number of log calls.
@ All
All flags set.
@ SPTR
Source path trim rules.
@ Once
Log once counters.
@ ThreadMappings
Named threads.
lox::Verbosity Verbosity
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
system::Path Path
Type alias in namespace alib.
Definition path.inl:375
lox::ESC ESC
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
lox::Scope Scope
Type alias in namespace alib.