ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
reportwriter.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 !defined(ALIB_DOX)
10#if !defined (HPP_ALIB_ALOX_REPORT_WRITER)
12#endif
13
14#if !defined (HPP_ALIB_ALOXMODULE)
16#endif
17#endif // !defined(ALIB_DOX)
18
19
20namespace alib { namespace lox {
21
23{
24 this->lox= pLox;
25
26 #if ALIB_DEBUG
27 pLox->Acquire( ALIB_CALLER );
28
29 pLox->GetLogableContainer().Add( A_CHAR("ALoxReportWriter set") );
30 pLox->Entry( ALoxReportWriter::LogDomain(), Verbosity::Verbose );
31
32 pLox->Release ();
33 #else
34
35 #endif
36}
37
39{
40 #if ALIB_DEBUG
41 lox->Acquire( msg.File, msg.Line, msg.Function );
42
43 auto& logables= lox->GetLogableContainer();
44 logables.Add( msg );
45
46 auto verbosity= msg.Type == lang::Report::Types::Error ? Verbosity::Error :
47 msg.Type == lang::Report::Types::Warning ? Verbosity::Warning :
48 msg.Type == lang::Report::Types::Message ? Verbosity::Info :
49 Verbosity::Verbose ;
50
52
53 // detect subdomain
54 NString256 detectedDomain;
55 if( logables.Size() > 1
56 && logables[0].IsArrayOf<nchar>() )
57 {
58 bool illegalCharacterFound= false;
59 NString firstArg= logables[0].Unbox<NString>();
60 for( integer idx= 0 ; idx< firstArg.Length() ; ++idx )
61 {
62 char c= firstArg[idx];
63 if (! ( isdigit( c )
64 || ( c >= 'A' && c <= 'Z' )
65 || c == '-'
66 || c == '_'
67 || c == '/'
68 || c == '.'
69 ) )
70 {
71 illegalCharacterFound= true;
72 break;
73 }
74 }
75
76 if(!illegalCharacterFound)
77 {
78 detectedDomain << domain << '/' << firstArg;
79 domain= detectedDomain;
80 logables.erase( logables.begin() );
81 }
82 else
84 }
85
86 lox->Entry( domain, verbosity );
87
88 lox->Release ();
89 #else
90 (void) msg;
91 #endif
92}
93
95
102
103
104}} // namespace [alib::lox]
@ Message
A report message.
ALIB_API ALoxReportWriter(Lox *lox)
virtual void Report(lang::Message &msg) override
static ALIB_API NString & LogDomain()
static NString16 reportDomain
void Entry(const NString &domain, Verbosity verbosity)
Definition lox.inl:1003
static constexpr NString InternalDomains
Definition lox.inl:121
void Release()
Definition lox.inl:210
Boxes & GetLogableContainer()
Definition lox.inl:980
void Acquire(const NCString &file, int line, const NCString &func)
Definition lox.inl:201
constexpr bool IsEmpty() const
Definition string.hpp:414
constexpr integer Length() const
Definition string.hpp:357
#define ALIB_CALLER
Definition alib.hpp:835
#define A_CHAR(STR)
Definition alib.cpp:57
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:286