ALib C++ Library
Library Version: 2412 R0
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 !DOXYGEN
11# include "alib/alox/aloxcamp.hpp"
12#endif // !DOXYGEN
13
14namespace alib { namespace lox {
15
17{
18 this->lox= pLox;
19
20 #if ALIB_DEBUG
21 pLox->Acquire( ALIB_CALLER );
22
23 pLox->GetLogableContainer().Add( A_CHAR("ALoxReportWriter set") );
24 pLox->Entry( ALoxReportWriter::LogDomain(), Verbosity::Verbose );
25
26 pLox->Release ();
27 #else
28
29 #endif
30}
31
33{
34 #if ALIB_DEBUG
35 lox->Acquire( msg.CI );
36
37 auto& logables= lox->GetLogableContainer();
38 logables.Add( msg );
39
40 auto verbosity= msg.Type == lang::Report::Types::Error ? Verbosity::Error :
41 msg.Type == lang::Report::Types::Warning ? Verbosity::Warning :
42 msg.Type == lang::Report::Types::Message ? Verbosity::Info :
43 Verbosity::Verbose ;
44
46
47 // detect subdomain
48 NString256 detectedDomain;
49 if( logables.Size() > 1
50 && logables[0].IsArrayOf<nchar>() )
51 {
52 bool illegalCharacterFound= false;
53 NString firstArg= logables[0].Unbox<NString>();
54 for( integer idx= 0 ; idx< firstArg.Length() ; ++idx )
55 {
56 char c= firstArg[idx];
57 if (! ( isdigit( c )
58 || ( c >= 'A' && c <= 'Z' )
59 || c == '-'
60 || c == '_'
61 || c == '/'
62 || c == '.'
63 ) )
64 {
65 illegalCharacterFound= true;
66 break;
67 }
68 }
69
70 if(!illegalCharacterFound)
71 {
72 detectedDomain << domain << '/' << firstArg;
73 domain= detectedDomain;
74 logables.erase( logables.begin() );
75 }
76 else
78 }
79
80 lox->Entry( domain, verbosity );
81
82 lox->Release ();
83 #else
84 (void) msg;
85 #endif
86}
87
89
96
97
98}} // namespace [alib::lox]
99
TBoxes & Add()
Definition boxes.inl:74
@ Message
A report message.
Lox * lox
The Lox to report to.
ALIB_API ALoxReportWriter(Lox *lox)
virtual void Report(lang::Message &msg) override
static ALIB_API NString & LogDomain()
static NString16 reportDomain
The internal domain to report into.
This class acts as a container for Loggers and provides a convenient interface to logging.
Definition lox.inl:58
BoxesMA & GetLogableContainer()
Definition lox.inl:937
void Entry(const NString &domain, Verbosity verbosity)
Definition lox.inl:960
static constexpr NString InternalDomains
Definition lox.inl:92
void Release()
Definition lox.inl:167
void Acquire(const lang::CallerInfo &ci)
Definition lox.inl:161
constexpr bool IsEmpty() const
Definition string.hpp:383
constexpr integer Length() const
Definition string.hpp:326
#define ALIB_CALLER
Definition alib.hpp:1164
#define A_CHAR(STR)
Definition alib.cpp:69
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273
CallerInfo CI
The source code location that this message relates to.
Definition message.hpp:34