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