ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
plaintextlogger.cpp
1using namespace alib;
2using namespace alib::lox;
3using namespace alib::lox::detail;
4using namespace alib::lox::textlogger;
5
8 AString& msg,
10 int,
11 bool ) {
13 return;
14
15 // loop over message, print the parts between the escape sequences
16 integer msgLength= msg.Length();
17 integer start= 0;
18 integer end;
19 integer column= 0;
20 while( start < msgLength ) {
21 bool foundESC= true;
22 end= msg.String::IndexOf<NC>( '\x1B', start );
23 if( end < 0 ) {
24 foundESC= false;
25 end= msgLength ;
26 }
27
28 if( end > start ) {
29 integer logWidth= logPlainTextPart( msg, start, end - start );
30 if ( logWidth < 0 )
31 return;
32 column+= logWidth;
33 }
34
35 // interpret escape sequence
36 if ( foundESC ) {
37 character c= msg[++end];
38
39 // auto tab or end of meta info part
40 if ( c == 't' || c == 'A') {
41 ++end;
42 c= msg[end++];
43 int extraSpace= c >= '0' && c <= '9' ? c - '0'
44 : c - 'A' + 10;
45
46 integer tabStop= varFormatAutoSizes.Get<FormatAutoSizes>().Main.Next(
47 AutoSizes::Types::Tabstop, column, extraSpace );
48
49 if ( tabStop > column ) {
50 AlignedCharArray spaces( ' ' );
51 integer remaining= tabStop - column;
52 while ( remaining > 0 ) {
53 integer size= remaining < spaces.Length() ? remaining
54 : spaces.Length();
55 if( logPlainTextPart( String(spaces.Buffer(), spaces.Length()), 0, size ) < 0 )
56 return;
57 remaining-= size;
58 }
59 column= tabStop;
60 } }
61
62 // prune or ignore all others
63 else {
64 if ( !PruneESCSequences )
65 if( logPlainTextPart( msg, end - 1, 3 ) < 0)
66 return;
67 end+= 2;
68 } }
69
70 // next
71 start= end;
72
73 } // write loop
74
75 ALIB_ASSERT_WARNING( start == msgLength, "ALOX", "Loop error when pruning ESC codes" )
77}
#define ALIB_ASSERT_WARNING(cond, domain,...)
virtual void logText(detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber, bool isRecursion) override
virtual bool notifyPlainTextLogOp(lang::Phase phase)=0
virtual integer logPlainTextPart(const String &buffer, integer start, integer length)=0
constexpr integer Length() const
Definition string.hpp:300
@ Tabstop
denotes a tab stop entry.
Definition autosizes.hpp:55
@ Begin
The start of a transaction.
@ End
The end of a transaction.
This namespaces defines class #"%TextLogger" and its helpers.
Definition loxpimpl.hpp:13
Definition alox.cpp:14
characters::AlignedCharArray<> AlignedCharArray
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
characters::character character
Type alias in namespace #"%alib".
constexpr integer Length() const noexcept
constexpr TChar * Buffer() noexcept