ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alox_init.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/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_license".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace lox {
9
10//==================================================================================================
11/// This enum is used in \alox to control the "verbosity" or "verboseness" of the log output.
12/// The values herein - apart from special value 'Off' - are sorted in the following order
13/// - Verbose (highest level)
14/// - Info
15/// - Warning
16/// - Error (lowest level).
17///
18/// A value of this set is provided to \alox in two different ways:
19/// First, all methods of class #"alib::lox::Lox;Lox" that execute a log operation
20/// assign a value of this enum to the <em>Log Statement</em>. Secondly, the overloaded methods
21/// #"Lox::SetVerbosity(detail::Logger*)", are defining the 'accepted'
22/// <em>minimal Verbosity</em> for a pair of <em><Logger/Log Domain></em>.
23///
24/// \alox, when executing a statement, checks both values against each other.
25/// A <em>Log Statement</em> is executed, when the <em><Logger/Log Domain></em> setting is set
26/// to the same or a 'higher level'. For example, if a <em><Logger/Log Domain></em> setting is
27/// \b Warning, then <em>Log Statements</em> with associated #"Verbosity::Warning;2" and
28/// #"Verbosity::Error" are executed and those with #"Verbosity::Info" and #"VerbosityVerbose" are
29/// suppressed.
30///
31/// If the special value #"%Verbosity::Off" is used with
32/// #"Lox::SetVerbosity(detail::Logger*);Lox::SetVerbosity",
33/// all logging is switched off for this pair of <em><Logger/Log Domain></em>.
34///
35/// Some of the <em>Log Statements</em> accept the parameter directly (e.g. #"Lox::Entry",
36/// #"Lox::Once(const NString&, Verbosity, const Box&, const String&, Scope, int);Lox::Once", and
37/// #"Lox::If(bool, const NString&, Verbosity, BoxedObjects&& ...);Lox::If"), while others
38/// inherently use the right value as their method name suggests (e.g.
39/// #"Lox::Error",
40/// #"Lox::Warning",
41/// #"Lox::Info",
42/// #"Lox::Verbose" and
43/// #"Lox::Assert").
44/// The latter group of methods do not support verbosity value #"%Verbosity::Off".
45///
46/// If the special value #"%Verbosity::Off" is used with those <em>Log Statements</em> that allow
47/// specifying the \e Verbosity as a parameter, the <em>Log Statement</em> is never executed.
48/// This is useful if the parameter is determined at runtime, depending on the state of an
49/// application.
50//==================================================================================================
51enum class Verbosity : uint8_t {
52 /// Statements with this value associated are never logged (useful if \e Verbosity is
53 /// evaluated at runtime). <em>Log Domains</em> with this setting do not execute any
54 /// <em>Log Statement</em>.
56
57 /// A \e Verbosity for error messages.
58 /// It is suppressed only if a <em>Log Domain</em>'s setting is #"%Verbosity::Off".
60
61 /// A \e Verbosity for warning messages, hence things that might lead to errors or are not
62 /// welcome for other reasons, but maybe are not errors.<br>
63 /// Logged if a <em>Log Domain</em> is set to #"%Verbosity::Warning", #"%Verbosity::Info" or
64 /// #"%Verbosity::Verbose".
66
67 /// The standard \e Verbosity for normal log output statements.
68 /// Logged if a <em>Log Domain</em> is set to #"%Verbosity::Info" or #"%Verbosity::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 /// #"%Verbosity::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, #"%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 /// Denotes the global (singleton) scope.
109
110 /// Denotes the actual thread as the scope. When used with <em>Scope Domains</em>,
111 /// 'inner' scopes can be defined optionally by multiple definitions.
113
114 /// Denotes the actual source file as the scope.
116
117 /// Denotes the actual method as the scope.
119
120 /// Denotes the actual thread as the scope. When used with <em>Scope Domains</em>,
121 /// 'inner' scopes can be defined optionally by multiple definitions.
123
124 /// Denotes the actual source path as the scope. By adding positive integral values
125 /// to this element (the enum type is an #"ArithmeticalTraits;ALib arithmetical enum"),
126 /// 'outer' \e Scopes of this scope level itself can be defined using parent directories
127 /// of the path.
129};
130
131//==================================================================================================
132/// This class defines "escape sequences" that influence the formatting of log output.
133/// Specific implementations of class
134/// #"alib::lox::detail::Logger;Logger"
135/// have to convert or interpret this classes definitions of escape sequences
136/// when processing log data. If no formatting of the output is supported by a specific Logger
137/// implementation, such logger should filter and discard escape sequences defined here.
138///
139/// The sequences are similar to ANSI Escape sequences and logger classes that
140/// log to 'VT100' compatible terminals will simply convert them.
141///
142/// The name of the class was intentionally chosen to be short, because the escape codes
143/// defined with this class will be concatenated to log strings like that:
144///
145/// \snippet "ut_alox_dox.cpp" DOX_ALOX_ESC
146///
147/// \note
148/// With the introduction of own, \alox specific escape codes, software that uses ALox becomes
149/// independent of any underlying, platform-specific sequences. For example, \alox is not relying
150/// on ANSI color codes, which are not supported by colorful Windows consoles. Instead, on each
151/// platform, dedicated Loggers will perform the translation of \alox codes to platform-specific
152/// ones.
153//==================================================================================================
154class ESC {
155 public:
156 static constexpr character RED [4]{ A_CHAR("\033c0") }; ///< Select red color for foreground.
157 static constexpr character GREEN [4]{ A_CHAR("\033c1") }; ///< Select green color for foreground.
158 static constexpr character YELLOW [4]{ A_CHAR("\033c2") }; ///< Select yellow color for foreground.
159 static constexpr character BLUE [4]{ A_CHAR("\033c3") }; ///< Select blue color for foreground.
160 static constexpr character MAGENTA [4]{ A_CHAR("\033c4") }; ///< Select magenta color for foreground.
161 static constexpr character CYAN [4]{ A_CHAR("\033c5") }; ///< Select cyan color for foreground.
162 static constexpr character BLACK [4]{ A_CHAR("\033c6") }; ///< Select black color for foreground.
163 static constexpr character WHITE [4]{ A_CHAR("\033c7") }; ///< Select white color for foreground.
164 static constexpr character GRAY [4]{ A_CHAR("\033c8") }; ///< Select gray color for foreground.
165 static constexpr character FG_RESET [4]{ A_CHAR("\033c9") }; ///< Select std color for foreground.
166
167 static constexpr character BG_RED [4]{ A_CHAR("\033C0") }; ///< Select red color for background.
168 static constexpr character BG_GREEN [4]{ A_CHAR("\033C1") }; ///< Select green color for background.
169 static constexpr character BG_YELLOW [4]{ A_CHAR("\033C2") }; ///< Select yellow color for background.
170 static constexpr character BG_BLUE [4]{ A_CHAR("\033C3") }; ///< Select blue color for background.
171 static constexpr character BG_MAGENTA [4]{ A_CHAR("\033C4") }; ///< Select blue color for background.
172 static constexpr character BG_CYAN [4]{ A_CHAR("\033C5") }; ///< Select blue color for background.
173 static constexpr character BG_BLACK [4]{ A_CHAR("\033C6") }; ///< Select red color for background.
174 static constexpr character BG_WHITE [4]{ A_CHAR("\033C7") }; ///< Select blue color for background.
175 static constexpr character BG_GRAY [4]{ A_CHAR("\033C8") }; ///< Select gray color for background.
176 static constexpr character BG_RESET [4]{ A_CHAR("\033C9") }; ///< Select std color for background.
177
178 static constexpr character BOLD [4]{ A_CHAR("\033sB") }; ///< Select bold font style.
179 static constexpr character ITALICS [4]{ A_CHAR("\033sI") }; ///< Select italics font style.
180 static constexpr character STYLE_RESET[4]{ A_CHAR("\033sr") }; ///< Select standard font style.
181 static constexpr character RESET [4]{ A_CHAR("\033sa") }; ///< Reset color and style.
182
183 static constexpr character URL_START [4]{ A_CHAR("\033lS") }; ///< Mark the start of an URL.
184 static constexpr character URL_END [4]{ A_CHAR("\033lE") }; ///< Mark the end of an URL.
185 static constexpr character TAB [4]{ A_CHAR("\033t0") }; ///< Go to next tab. Usually, text loggers will increase the tab position automatically.
186
187 static constexpr character EOMETA [4]{ A_CHAR("\033A0") }; ///< End of meta-information in log string
188
189 /// Replaces ESC codes in a string reversely to "ESC::XXX".
190 /// @param target The string to replace in.
191 /// @param startIdx The index to start searching for ESC codes.
193 static void ReplaceToReadable( AString& target, integer startIdx );
194}; // class ESC
195
196
197/// Denotes flags used with methods #"Lox::GetState;*" and #"Lox::State;*" to select
198/// different parts of the state receive.
199enum class StateInfo {
200 NONE = 0, ///< No state
201 Basic = 1 << 0, ///< Name and number of log calls
202 Version = 1 << 1, ///< Library Version and thread safeness
203 Loggers = 1 << 2, ///< Loggers
204
205 Domains = 1 << 3, ///< Log domains currently registered
206 InternalDomains = 1 << 4, ///< Internal domains
207 ScopeDomains = 1 << 5, ///< Scope domains
208 DSR = 1 << 6, ///< Domain substitution rules
209 PrefixLogables = 1 << 7, ///< Prefix logables
210 Once = 1 << 8, ///< Log once counters
211 LogData = 1 << 9, ///< Log data objects
212 ThreadMappings = 1 << 10, ///< Named threads
213
214 SPTR = 1 << 20, ///< Source path trim rules
215 CompilationFlags = 1 << 21, ///< \alib/\alox compilation flags
216
217 All = ~0L, ///< All flags set.
218};
219
220
221} // namespace alib[::lox]
222
223
224/// Type alias in namespace #"%alib".
226
227/// Type alias in namespace #"%alib".
229
230/// Type alias in namespace #"%alib".
232
233} // namespace [alib]
234
235
238
239
243
244
#define ALIB_DLL
#define A_CHAR(STR)
#define ALIB_EXPORT
#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:9
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.
Definition alox.cpp:14
lox::Verbosity Verbosity
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
system::Path Path
Type alias in namespace #"%alib".
Definition path.hpp:417
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".