ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
aloxcamp.cpp
1
2
3namespace alib {
4
6
7//==================================================================================================
8/// This is the \b C++ version of <b>ALox Logging Library</b>, which has been integrated
9/// as one of many modules into the <b>ALib C++ Framework</b>.<br>
10///
11/// Please check out the #"alib_mod_alox;documentation of ALib Module ALox" for more
12/// information.
13//==================================================================================================
14namespace lox {
15
16#if !DOXYGEN
17namespace {
18void bulkloadResources(ResourcePool& resourcePool, const NCString& resourceCategory) {
19 resourcePool.BootstrapBulk( resourceCategory,
20
21 // ALIB-RESOURCE-COMPILER-REPLACEMENT-START
22 "Var0" , A_CHAR("1|ALOX/NO_IDE_LOGGER|B"),
23 "Var1" , A_CHAR("2|ALOX/CONSOLE_TYPE|S"),
24 "Var2" , A_CHAR("3|ALOX/%2/VERBOSITY_WITH_%1|ALOXV"),
25 "Var3" , A_CHAR("4|ALOX/GLOBAL_SOURCE_PATH_TRIM_RULES|S"),
26 "Var4" , A_CHAR("5|ALOX/%1/SOURCE_PATH_TRIM_RULES|S"),
27 "Var5" , A_CHAR("6|ALOX/%1/DOMAIN_SUBSTITUTION|SV;"),
28 "Var6" , A_CHAR("7|ALOX/%1/PREFIXES|S"),
29 "Var7" , A_CHAR("8|ALOX/%1/DUMP_STATE_ON_EXIT|S"),
30 "Var8" , A_CHAR("20|ALOX/%1/AUTO_SIZES|ALOXAS"),
31 "Var9" , A_CHAR("21|ALOX/%1/FORMAT|ALOXFMI"),
32 "Var10" , A_CHAR("22|ALOX/%1/FORMAT_DATE_TIME|ALOXFDT"),
33 "Var11" , A_CHAR("23|ALOX/%1/FORMAT_MULTILINE|ALOXFML"),
34 "Var12" , A_CHAR("24|ALOX/%1/FORMAT_TIME_DIFF|ALOXFTD"),
35 "Var13" , A_CHAR("25|ALOX/%1/FORMAT_OTHER|ALOXFO"),
36 "Var14" , A_CHAR("26|ALOX/%1/REPLACEMENTS|ALOXSR"),
37 "Var15" , A_CHAR("27|ALOX/CONSOLE_LIGHT_COLORS|ALOXCLP"),
38 "Var16" , A_CHAR("28|ALOX/CODEPAGE|I"),
39 "Var_D1" , A_CHAR("false"),
40 "Var_D2" , A_CHAR("default"),
41 "Var_D8" , A_CHAR("none, verbosity=info, domain=/ALOX"),
42 "Var_D22" , A_CHAR("yyyy-MM-dd,HH:mm:ss, Days"),
43 "Var_D23" , A_CHAR("2,ALox: Multi-line message follows: ,> ,,nulled,\\r"),
44 "Var_D24" , A_CHAR("1000,--- , ns, \u03BCs, ms, s, m, h, days"),
45 "Var_D25" , A_CHAR("---, ---, 3"),
46 "Var_C1" , A_CHAR("If true, the creation of an additional, ide-specific debug logger is suppressed."),
47 "Var_C2" , A_CHAR("Influences the type of console logger to be created by method\n")
48 A_CHAR("Lox::CreateConsoleLogger which is also used by Log::AddDebugLogger\n")
49 A_CHAR("Possible values are: default, plain, ansi, and windows."),
50 "Var_C3" , A_CHAR("The verbosities of logger %2 in lox %1. Supports wildcards for domain paths.\n")
51 A_CHAR("Format: [ExportAll ;] [[*]domainpath[*] = Verbosity] [;...]"),
52 "Var_C4" , A_CHAR("Defines global source path trim rules (applicable for all Lox instances).\n")
53 A_CHAR("Format: [ [*]sourcepath [, inclusion, trimoffset, sensitivity, replacement] ] [;...]"),
54 "Var_C5" , A_CHAR("Defines source path trim rules for Lox %1.\n")
55 A_CHAR("Format: [ [*]sourcepath [, inclusion, trimoffset, sensitivity, replacement] ] [;...]"),
56 "Var_C7" , A_CHAR("Prefix strings for log domains of lox %1.\n")
57 A_CHAR("Format: [ [*]domainpath[*] = prefixstring [, inclusion] ] [;...]"),
58 "Var_C8" , A_CHAR("Log information about lox %1 on exit. Comma separated list of arguments define\n")
59 A_CHAR("verbosity, domain and content of output. Possible values content arguments are:\n")
60 A_CHAR("All, Basic, Version, SPTR, Loggers, Domains, InternalDomains\n")
61 A_CHAR("ScopeDomains, DSR, PrefixLogables Once, LogData, ThreadMappings,\n")
62 A_CHAR("CompilationFlags. If NONE is given nothing is dumped."),
63 "Var_C20" , A_CHAR("Detected field sizes and tabulator positions of the meta-information portion and the\n")
64 A_CHAR("those of the log output, separated by ';'. (These is a generated and temporary values)."),
65 "Var_C21" , A_CHAR("Meta info format of logger %1, including signatures for verbosity strings and\n")
66 A_CHAR("a string added to the end of each log statement.\n")
67 A_CHAR("Format: MetaInfo,Error,Warning,Info,Verbose,MsgSuffix"),
68 "Var_C22" , A_CHAR("Date and time format of logger %1.\n")
69 A_CHAR("Format: Date,Time,ElapsedDays"),
70 "Var_C23" , A_CHAR("Multi-line format of logger %1.\n")
71 A_CHAR("Format: Mode,Headline,Prefix,Suffix,Delimiter,DelimiterReplacement"),
72 "Var_C24" , A_CHAR("Time difference entities of logger %1.\n")
73 A_CHAR("Format: Minimum,None,Nanos,Micros,Millis,Secs,Mins,Hours, Days"),
74 "Var_C25" , A_CHAR("Specifies three further format values: 1. A replacement string if no file name is available,\n")
75 A_CHAR("2. A replacement string if no method name is available and 3. The minimum digits of the\n")
76 A_CHAR("log counter."),
77 "Var_C26" , A_CHAR("Pairs of search and replacement strings for text logger %1.\n")
78 A_CHAR("Format: [search,replacement] [,...]"),
79 "Var_C27" , A_CHAR("Evaluated by colorful loggers that dispose of light and dark colors. Those may adjust\n")
80 A_CHAR("their foreground and background color accordingly. If not given, under Windows OS the right\n")
81 A_CHAR("value is detected. Otherwise the value defaults to \foreground. In some occasions, the\n")
82 A_CHAR("(detected or set) runtime environment might also indicate a different default value.\n")
83 A_CHAR("Possible values are 'Auto', Foreground', 'Background' and 'Never'."),
84 "Verbosity" , A_CHAR("0,Off,1,1,Error,1,1,Errors,1,2,Warning,1,2,Warnings,1,3,Info,1,4,Verbose,1"),
85 "Scope" , A_CHAR("0,Global,1,1,ThreadOuter,7,2,Filename,1,3,Method,1,4,ThreadInner,7,5,Path,7"),
86 "StateInfo" , A_CHAR("0,NONE,1,1,Basic,1,2,Version,1,^9,LogData,4,4,Loggers,1,^6,DSR,2,8,Domains,1,^4,InternalDomains,1,0x100000,SPTR,2,^5,ScopeDomains,1,^7,PrefixLogables,1,^8,Once,1,^10,ThreadMappings,1,^21,CompilationFlags,1,0xFFFFFFFF,All,1"),
87 "LCU" , A_CHAR("0,Auto,1,1,Never,1,2,Foreground,2,3,Background,2,2,ForeGround,1,3,BackGround,1"),
88 "VVEA" , A_CHAR("ExportAll"),
89 "TLFmtExc" , A_CHAR("\nAn exception occurred during formatting ALox logables:\n"),
90 "CFG_SECT_CMT_ALOX", A_CHAR("@>'/// '@HL-Settings controlling ALox log output.\n")
91 A_CHAR("@HL-"),
92 // ALIB-RESOURCE-COMPILER-REPLACEMENT-END
93
94 // end of BootstrapBulk()
95 nullptr );
96}
97} // anonymous namespace
98#endif // !DOXYGEN
99
100
102: Camp( "ALOX" ) {
103 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
104 ALIB_ASSERT_ERROR( this == &ALOX, "ALOX",
105 "Instances of class ALox must not be created. Use singleton alib::ALOX" )
106 #endif
107}
108
110 #if ALOX_DBG_LOG
111 if (Log::DEBUG_LOGGER != nullptr )
113
115 #endif
116
117 ALIB_ASSERT_ERROR(detail::dbgCountLoxes() == 0, "ALOX", "A Lox remained from the last test" )
118
119 #if ALOX_DBG_LOG
120 new (DEBUG_LOX) Lox( "LOG" );
121 #endif
122}
123
124//##################################################################################################
125// Compilation Flags
126//##################################################################################################
127
128// check the configuration macros, give warning once (therefore not in HPP)
129#if !ALOX_DBG_LOG && ALOX_DBG_LOG_CI
130# pragma message ( "Warning: ALox configuration macro mismatch: ALOX_DBG_LOG_CI is true, while ALOX_DBG_LOG is false." )
131#endif
132#if !ALOX_REL_LOG && ALOX_REL_LOG_CI
133# pragma message ( "Warning: ALox configuration macro mismatch: ALOX_REL_LOG_CI is true, while ALOX_REL_LOG is false" )
134#endif
135
136//##################################################################################################
137// ALox module initialization
138//##################################################################################################
139
142#if !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
143 // now, we just add the resources that parent App did not define for us.
145 if(!rc.Do( "aloxcamp.alibrc", __FILE__, *this, ResourceCategory, true,
146 __FILE__ )
147 // nullptr )
148 )
149 bulkloadResources(GetResourcePool(), ResourceCategory);
150
151 // a few resources cannot be defined using the resource compiler, as their value
152 // depends on the build type.
153 resourcePool->BootstrapBulk( ResourceCategory,
154
155 // standard textlogger format string
157 "Var_D21", A_CHAR("%SF:%SL:%A3%SM %A3[%TC +%TL][%tN][%D]%A1#%# %V: ")
158 #else
159 "Var_D21", A_CHAR("[%TC +%TL][%tN][%D]%A1#%# %V: ")
160 #endif
161 A_CHAR(",[ERR],[WRN], ,[***]") ,
162
163 // ANSI textlogger format string
165 "Var_D21A", A_CHAR("%SF:%SL:%A3%SM %A3[%TC +%TL][%tN][%D]%A1#%#: %V")
166 #else
167 "Var_D21A", A_CHAR("[%TC +%TL][%tN][%D]%A1#%#:%V")
168 #endif
169 A_CHAR( ",\033c0,\033c3,,\033c8,\033[0m" ) ,
170
171 #if defined(_WIN32)
172 "Var_D28", A_CHAR("65001"),
173 "Var_C28", A_CHAR("Code page used by class WindowsConsoleLogger. Defaults to 65001.\n"
174 "(Only used on Windows OS)" ) ,
175 #endif
176
177 #if ALIB_DEBUG
178 "CFG_SECT_CMT_ALOX/LOG", A_CHAR("@>'/// '@HL-Settings of the Lox-instance used with debug-logging.\n@HL-"),
179 "CFG_SECT_CMT_ALOX/DEBUG_LOGGER", A_CHAR("@>'/// '@HL-Settings of the debug-logger.\n@HL-"),
180 #endif
181
182 // end of BootstrapBulk()
183 nullptr );
184
185#endif // !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
186 }
187
188DOX_MARKER([DOX_VARIABLES_DEFINETYPE3])
189//...
190//...
192 ALIB_VARIABLES_REGISTER_TYPE( FormatMetaInfo )
193 //...
194 //...
195DOX_MARKER([DOX_VARIABLES_DEFINETYPE3])
197 ALIB_VARIABLES_REGISTER_TYPE( FormatDateTime )
198 ALIB_VARIABLES_REGISTER_TYPE( FormatTimeDiff )
199 ALIB_VARIABLES_REGISTER_TYPE( FormatMultiLine )
200 ALIB_VARIABLES_REGISTER_TYPE( FormatOther )
201 ALIB_VARIABLES_REGISTER_TYPE( FormatAutoSizes )
202 ALIB_VARIABLES_REGISTER_TYPE( Replacements )
203 ALIB_VARIABLES_REGISTER_TYPE( ColorfulLoggerParameters )
204
205 // Parse enum records
210 ColorfulLoggerParameters::
211 LightColorUsage >( *this, "LCU" );
212
214
215 // preload all variable with declarations (and without placeholders)
216 config->PreloadVariables<lox::Variables>();
217 }
218
220 #if ALOX_DBG_LOG
221 if ( !DEBUG_LOX )
223 #endif
224} }
225
226
228 (void) phase;
229 #if ALOX_DBG_LOG
230 if( phase == ShutdownPhases::Destruct ) {
231 if ( Log::DEBUG_LOGGER != nullptr )
233
234 if ( DEBUG_LOX )
236
238 }
239 #endif
240}
241
242
243}} // namespace [alib::lox]
244
245#if !DOXYGEN
246namespace alib { namespace strings {
248 const lox::Scope src ) {
249 Scope scope= src;
250 int pathLevel= int( scope - Scope::Path );
251 if(pathLevel > 0 )
252 scope= Scope::Path;
253
254 target << "Scope::" << enumrecords::GetRecord(scope).EnumElementName;
255
256 if( pathLevel > 0 )
257 target << '+' << pathLevel;
258}
259
260void AppendableTraits<Pair<Verbosity, Priority>,nchar, lang::HeapAllocator>::operator()(
261 NAString& target, const Pair<Verbosity, Priority>& src ) {
262 target._( NField( src.First, 7, lang::Alignment::Left) );
263 target._( '(' )._( src.Second );
264 target.InsertAt(")",target.LastIndexOfAny<lang::Inclusion::Exclude>(NDEFAULT_WHITESPACES) + 1 );
265}
266}}
267
268// CVVerbosities
269namespace alib::variables::detail {
270ALIB_DLL void VMeta_CVVerbosities::imPort(VDATA* data, Configuration&,
271 const StringEscaper& esc , const String& src) {
272 auto& cvVerbosities= data->As<alib::lox::CVVerbosities>();
273 auto& exportAllKeyWord= alib::ALOX.GetResource("VVEA");
274 cvVerbosities.ExportAll= false;
275
277 StringVectorMA results(la);
278 esc.UnescapeTokens(results, src, A_CHAR(";"));
279 cvVerbosities.Clear();
280 for( auto& it : results ) {
281 Substring value= it;
282 value.Trim(A_CHAR("\r\n"));
283
284 if( value.Equals<CHK, lang::Case::Ignore>(exportAllKeyWord) ) {
285 cvVerbosities.ExportAll= true;
286 continue;
287 }
288 cvVerbosities.Add( value );
289} }
290
291ALIB_DLL void VMeta_CVVerbosities::exPort( VDATA* data, Configuration&,
292 const StringEscaper& esc , AString& dest) {
293 auto& cvVerbosities= data->As<alib::lox::CVVerbosities>();
294 auto& exportAllKeyWord= alib::ALOX.GetResource("VVEA");
295 if( cvVerbosities.ExportAll)
296 dest << exportAllKeyWord << " ;" << NEW_LINE;
297
298 if( !cvVerbosities.IsEmpty()) // well, this can only be empty if a user makes mistakes
299 for( auto it= cvVerbosities.begin() ;; ) {
300 esc.Escape(*it, dest, A_CHAR(";"));
301
302 if( ++it == cvVerbosities.end() )
303 break;
304
305 dest << " ;";
306 dest << NEW_LINE;
307} }
308} //namespace [alib::variables::detail]
309
310#endif // !DOXYGEN
#define ALIB_DLL
#define ALOX_DBG_LOG_CI
#define A_CHAR(STR)
#define ALOX_REL_LOG_CI
#define ALIB_DEBUG
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define Log_RemoveDebugLogger()
BootstrapPhases GetBootstrapState()
Definition camp.hpp:158
SharedConfiguration config
Definition camp.hpp:96
Camp(const NCString &resourceCategory)
Definition camp.hpp:104
bool Do(const NString &alibrcFileName, const NString &callingFile, Camp &campInstance, const NString &resourceCategory, bool allowReplacements, const NString &cppFileName)
void Bootstrap() override
Implementation of #"Camp::Bootstrap;*".
Definition aloxcamp.cpp:140
void Shutdown(ShutdownPhases phase) override
Definition aloxcamp.cpp:227
static textlogger::TextLogger * DEBUG_LOGGER
The debug logger created by AddDebugLogger.
Definition log.hpp:39
This class acts as a container for Loggers and provides a convenient interface to logging.
Definition lox.hpp:13
const String & GetResource(const NString &name)
SPResourcePool resourcePool
Shared pointer to the resource pool.
virtual void BootstrapBulk(const nchar *category,...)=0
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
Definition camp.hpp:263
const RecordsTraits< TEnum >::Type & GetRecord(TEnum element)
Definition records.hpp:182
@ Left
Chooses left alignment.
void Destruct(T &object)
Definition tmp.hpp:82
@ Exclude
Chooses exclusion.
void shutdownLoxes()
Internal lox management.
integer dbgCountLoxes()
Lox * DEBUG_LOX
TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
VData< void * > VDATA
Definition vmeta.hpp:53
Definition alox.cpp:14
strings::TField< nchar > NField
Type alias in namespace #"%alib".
resources::ResourcePool ResourcePool
Type alias in namespace #"%alib".
strings::TCString< nchar > NCString
Type alias in namespace #"%alib".
Definition cstring.hpp:408
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
Definition camp.hpp:34
strings::util::TStringVector< character, MonoAllocator > StringVectorMA
Type alias in namespace #"%alib".
Definition vector.hpp:107
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
Definition cstring.hpp:536
lox::ALoxCamp ALOX
The singleton instance of ALib Camp class #"ALoxCamp".
Definition aloxcamp.cpp:5
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace #"%alib".
variables::Configuration Configuration
Type alias in namespace #"%alib".
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
Definition camp.hpp:40
@ Destruct
The main phase of termination that destructs everything.
Definition camp.hpp:44
lox::Lox Lox
Type alias in namespace #"%alib".
Definition lox.hpp:1303
strings::util::StringEscaper StringEscaper
Type alias in namespace #"%alib".
Definition escaper.hpp:181
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
boxing::Pair< T, U > Pair
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
characters::nchar nchar
Type alias in namespace #"%alib".
constexpr NCString NDEFAULT_WHITESPACES
A zero-terminated string of default whitespace characters.
Definition cstring.hpp:565
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
monomem::TLocalAllocator< 4 > LocalAllocator4K
Type alias in namespace #"%alib". Allocates 4kB of stack memory.
lox::Scope Scope
Type alias in namespace #"%alib".
void operator()(TAString< TChar > &target, const TAppendable &src)
#define ALIB_VARIABLES_REGISTER_TYPE(CPPName)