ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
variables.cpp
1// #################################################################################################
2// alib::lox::detail - ALox Logging Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !DOXYGEN
15#endif // !DOXYGEN
16
17
18#if !DOXYGEN
19
20// FormatMetaInfo
21DOX_MARKER([DOX_CONFIG_DEFINETYPE2])
22namespace alib::config::detail {
23
24void VMeta_FormatMetaInfo::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
25{
26 auto& rec = data->As<alib::lox::textlogger::FormatMetaInfo>();
28 StringVectorMA results(la);
29 escaper.UnescapeTokens(results, src, A_CHAR(",") );
30
31 rec.Format .Reset(results.TryGet(0));
32 rec.VerbosityError .Reset(results.TryGet(1));
33 rec.VerbosityWarning.Reset(results.TryGet(2));
34 rec.VerbosityInfo .Reset(results.TryGet(3));
35 rec.VerbosityVerbose.Reset(results.TryGet(4));
36 rec.MsgSuffix .Reset(results.TryGet(5));
37}
38
39void VMeta_FormatMetaInfo::exPort(VDATA* data, Configuration&, const StringEscaper& escaper, AString& dest)
40{
41 auto& rec= data->As<alib::lox::textlogger::FormatMetaInfo>();
42 escaper.Escape(rec.Format , dest, A_CHAR(",")); dest <<", " << NEW_LINE;
43 escaper.Escape(rec.VerbosityError , dest, A_CHAR(",")); dest <<", " << NEW_LINE;
44 escaper.Escape(rec.VerbosityWarning , dest, A_CHAR(",")); dest <<", " << NEW_LINE;
45 escaper.Escape(rec.VerbosityInfo , dest, A_CHAR(",")); dest <<", " << NEW_LINE;
46 escaper.Escape(rec.VerbosityVerbose , dest, A_CHAR(",")); dest <<", " << NEW_LINE;
47 escaper.Escape(rec.MsgSuffix , dest, A_CHAR(","));
48}
49
50} // namespace [alib::config::detail]
51DOX_MARKER([DOX_CONFIG_DEFINETYPE2])
52
53namespace alib::config::detail {
54
55// FormatDate
56ALIB_API void VMeta_FormatDateTime::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
57{
58 auto& rec= data->As<alib::lox::textlogger::FormatDateTime>();
60 StringVectorMA results(la);
61 escaper.UnescapeTokens(results, src, A_CHAR(","));
62
63 rec.Date .Reset(results.TryGet(0));
64 rec.TimeOfDay .Reset(results.TryGet(1));
65 rec.ElapsedDays.Reset(results.TryGet(2));
66}
67ALIB_API void VMeta_FormatDateTime::exPort(VDATA* data, Configuration& cfg, const StringEscaper& escaper, AString& dest)
68{
69 (void)cfg;
70 auto& rec= data->As<alib::lox::textlogger::FormatDateTime>();
71 escaper.Escape(rec.Date , dest, A_CHAR(",")); dest << A_CHAR(", ");
72 escaper.Escape(rec.TimeOfDay , dest, A_CHAR(",")); dest << A_CHAR(", ");
73 escaper.Escape(rec.ElapsedDays , dest, A_CHAR(","));
74}
75
76// FormatTimeDiff
77ALIB_API void VMeta_FormatTimeDiff::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
78{
79 auto& rec= data->As<alib::lox::textlogger::FormatTimeDiff>();
81 StringVectorMA results(la);
82 escaper.UnescapeTokens(results, src, A_CHAR(","));
83
84 rec.Minimum =int64_t(Substring( results.TryGet(0)).ParseDec());
85 rec.None .Reset( results.TryGet(1));
86 rec.Nanos .Reset( results.TryGet(2));
87 rec.Micros .Reset( results.TryGet(3));
88 rec.Millis .Reset( results.TryGet(4));
89 rec.Secs .Reset( results.TryGet(5));
90 rec.Mins .Reset( results.TryGet(6));
91 rec.Hours .Reset( results.TryGet(7));
92 rec.Days .Reset( results.TryGet(8));
93}
94ALIB_API void VMeta_FormatTimeDiff::exPort(VDATA* data, Configuration& cfg, const StringEscaper& escaper, AString& dest)
95{
96 (void)cfg;
97 auto& rec= data->As<alib::lox::textlogger::FormatTimeDiff>();
98 dest << rec.Minimum; dest << A_CHAR(", ");
99 escaper.Escape(rec.None , dest, A_CHAR(",")); dest << A_CHAR(", ");
100 escaper.Escape(rec.Nanos , dest, A_CHAR(",")); dest << A_CHAR(", ");
101 escaper.Escape(rec.Micros , dest, A_CHAR(",")); dest << A_CHAR(", ");
102 escaper.Escape(rec.Millis , dest, A_CHAR(",")); dest << A_CHAR(", ");
103 escaper.Escape(rec.Secs , dest, A_CHAR(",")); dest << A_CHAR(", ");
104 escaper.Escape(rec.Mins , dest, A_CHAR(",")); dest << A_CHAR(", ");
105 escaper.Escape(rec.Hours , dest, A_CHAR(",")); dest << A_CHAR(", ");
106 escaper.Escape(rec.Days , dest, A_CHAR(","));
107}
108
109// FormatMultiLine
110ALIB_API void VMeta_FormatMultiLine::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
111{
112 auto& rec= data->As<alib::lox::textlogger::FormatMultiLine>();
114 StringVectorMA results(la);
115 escaper.UnescapeTokens(results, src, A_CHAR(","));
116 String256 buf;
117
118 rec.Mode =int(Substring( results.TryGet(0) ).ParseDec());
119 rec.Headline .Reset(results.TryGet(1));
120 rec.Prefix .Reset(results.TryGet(2));
121 rec.Suffix .Reset(results.TryGet(3));
122 buf .Reset(results.TryGet(4));
123 if( !buf.StartsWith<CHK, lang::Case::Ignore>(A_CHAR("null")) )
124 rec.Delimiter .Reset(buf);
125 rec.DelimiterReplacement .Reset(results.TryGet(5));
126}
127
128ALIB_API void VMeta_FormatMultiLine::exPort(VDATA* data, Configuration& cfg, const StringEscaper& escaper, AString& dest)
129{
130 (void)cfg;
131 auto& rec= data->As<alib::lox::textlogger::FormatMultiLine>();
132 dest << rec.Mode ; dest << A_CHAR(", ");
133 escaper.Escape(rec.Headline , dest, A_CHAR(",")); dest << A_CHAR(", ");
134 escaper.Escape(rec.Prefix , dest, A_CHAR(",")); dest << A_CHAR(", ");
135 escaper.Escape(rec.Suffix , dest, A_CHAR(",")); dest << A_CHAR(", ");
136 if( rec.Delimiter.IsNotNull() )
137 escaper.Escape(rec.Delimiter , dest, A_CHAR(",")) << dest << A_CHAR(", ");
138 else
139 dest << "nulled, ";
140 escaper.Escape(rec.DelimiterReplacement , dest, A_CHAR(","));
141}
142
143// FormatOther
144ALIB_API void VMeta_FormatOther::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
145{
146 auto& rec= data->As<alib::lox::textlogger::FormatOther>();
148 StringVectorMA results(la);
149 escaper.UnescapeTokens(results, src, A_CHAR(","));
150
151 rec.NoSourceFileInfo .Reset(results.TryGet(0));
152 rec.NoMethodInfo .Reset(results.TryGet(1));
153 rec.LogNumberMinDigits= int(Substring( results.TryGet(2) ).ParseDec());
154}
155ALIB_API void VMeta_FormatOther::exPort(VDATA* data, Configuration&, const StringEscaper& escaper, AString& dest)
156{
157 auto& rec= data->As<alib::lox::textlogger::FormatOther>();
158#if ALIB_CHARACTERS_WIDE
159 String256 wNoSourceFileInfo(rec.NoSourceFileInfo);
160 String256 wNoMethodInfo (rec.NoMethodInfo );
161 escaper.Escape(wNoSourceFileInfo , dest, A_CHAR(",")); dest << A_CHAR(", ");
162 escaper.Escape(wNoMethodInfo , dest, A_CHAR(",")); dest << A_CHAR(", ");
163#else
164 escaper.Escape(rec.NoSourceFileInfo , dest, ","); dest << A_CHAR(", ");
165 escaper.Escape(rec.NoMethodInfo , dest, ","); dest << A_CHAR(", ");
166#endif
167 dest << rec.LogNumberMinDigits;
168}
169
170// FormatAutoSizes
171ALIB_API void VMeta_FormatAutoSizes::imPort(VDATA* data, Configuration&, const StringEscaper& , const String& src)
172{
173 auto& rec= data->As<alib::lox::textlogger::FormatAutoSizes>();
174
175 Substring importMI(src);
176 Substring importLog;
177 integer sepPos= importMI.IndexOf(';');
178 if( sepPos >= 0 )
179 importMI.Split( sepPos, importLog, 1 );
180 rec.Main .Import( importMI );
181 rec.LogMessage.Import( importLog );
182}
183
184ALIB_API void VMeta_FormatAutoSizes::exPort(VDATA* data, Configuration&, const StringEscaper& , AString& dest)
185{
186 auto& rec= data->As<alib::lox::textlogger::FormatAutoSizes>();
187 rec.Main .Export( dest );
188 dest << " ; ";
189 rec.LogMessage.Export( dest );
190}
191
192// Replacements
193ALIB_API void VMeta_Replacements::imPort(VDATA* data, Configuration&, const StringEscaper& escaper, const String& src)
194{
195 auto& pairs= data->As<alib::lox::textlogger::Replacements>().Pairs;
197 StringVectorMA results(la);
198 escaper.UnescapeTokens(results, src, A_CHAR("=,"));
199 int cnt= 0;
200 while(true)
201 {
202 String searchString= results.TryGet(cnt );
203 String replaceString= results.TryGet(cnt + 1);
204 if( searchString.IsEmpty() )
205 break;
206
207 pairs.insert( pairs.end(), AStringPA(pairs.get_allocator().GetAllocator()) );
208 pairs.back() << searchString;
209 pairs.insert( pairs.end(), AStringPA(pairs.get_allocator().GetAllocator()) );
210 pairs.back() << replaceString;
211 cnt+= 2;
212 }
213}
214
215ALIB_API void VMeta_Replacements::exPort(VDATA* data, Configuration&, const StringEscaper& escaper, AString& dest)
216{
217 auto& pairs= data->As<alib::lox::textlogger::Replacements>().Pairs;
218 for(auto it = pairs.begin() ; it != pairs.end() ; )
219 {
220 escaper.Escape(*it , dest, A_CHAR("=,"));
221 dest << "=";
222 ++it;
223 escaper.Escape(*it , dest, A_CHAR("=,"));
224 dest << ", ";
225 ++it;
226 }
227 dest.DeleteEnd(A_CHAR(", "));
228}
229
230// ColorfulLoggerParameters
231ALIB_API void VMeta_ColorfulLoggerParameters::imPort(VDATA* data, Configuration&, const StringEscaper&, const String& src)
232{
234 Substring p= src;
235 p.Trim();
237 {
238 ALIB_WARNING( "ALOX", "Error parsing variable CONSOLE_LIGHT_COLORS value {!Q'}.", src )
239 }
240}
241
242ALIB_API void VMeta_ColorfulLoggerParameters::exPort(VDATA* data, Configuration&, const StringEscaper&, AString& dest)
243{
245 dest << CLP.LCU;
246}
247
248} //namespace [alib::config::detail]
249#endif //if !DOXYGEN
250
integer IndexOf(TChar needle, integer startIdx=0) const
Definition string.hpp:896
ALIB_API uint64_t ParseDec(integer startIdx=0, TNumberFormat< TChar > *numberFormat=nullptr, integer *newIdx=nullptr) const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=TT_CStringConstants< TChar >::DefaultWhitespaces())
ALIB_API void Export(AString &target)
Definition autosizes.cpp:58
#define ALIB_WARNING(...)
Definition alib.hpp:1268
#define A_CHAR(STR)
#define ALIB_API
Definition alib.hpp:639
bool Parse(strings::TSubstring< TChar > &input, TEnum &result)
config::Configuration Configuration
Type alias in namespace alib.
monomem::TLocalAllocator< 4 > LocalAllocator4K
Type alias in namespace alib. Allocates 4kB of stack memory.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
Definition cstring.hpp:580
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
strings::TString< character > String
Type alias in namespace alib.
strings::util::StringEscaper StringEscaper
Type alias in namespace alib.
Definition escaper.hpp:206
strings::util::TStringVector< character, MonoAllocator > StringVectorMA
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273
strings::TAString< character, PoolAllocator > AStringPA
Type alias in namespace alib.
Definition astringpa.hpp:45
Parameters specific to colorful loggers. As of today, this simply has one attribute.
AutoSizes Main
The instance used with the meta info format string.
int64_t Minimum
Minimum time difference to log in nanoseconds. Below that None is written.