8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
24 import ALib.Containers.List;
27 import ALib.EnumRecords;
29 import ALib.EnumRecords.Bootstrap;
30 import ALib.Variables;
32 import ALib.Camp.Base;
33 import ALib.ALox.Impl;
52 while ( loxes.IsNotEmpty() )
81 for(
auto* it : detail::loxes )
88 Lox* newLox=
new Lox ( name,
false );
89 detail::loxes.emplace_back( newLox );
101 if (
lox ==
nullptr ) {
108 for(
auto search= detail::loxes.begin() ; search != detail::loxes.end() ; ++search )
109 if ( *search ==
lox ) {
110 (void) detail::loxes.erase( search );
113 ALIB_WARNING(
"ALOX",
"Given lox named \"{}\" could not be found for removal.",
114 lox !=
nullptr ?
lox->GetName() :
"<null>" )
119 for(
auto* it : detail::loxes )
120 if( it->GetName().Equals<
NC>(
lox->GetName() ) ) {
121 ALIB_ERROR(
"ALOX",
"Given lox named \"{}\" was already registered. "
122 "Registration ignored.",
lox->GetName() )
125 detail::loxes.emplace_back(
lox );
162 #if defined( _WIN32 )
167 ALIB_WARNING(
"ALOX",
"Unrecognized value in config variable \"{}\" = \"{}\".",
171 if( variable.
Define(variables::Priority::Standard) )
174 #if defined( _WIN32 )
194 static bool recursion=
false;
201 ALIB_WARNING(
"ALOX",
"Log::AddDebugLogger(): called twice." )
208 #if defined(_MSC_VER) && ALIB_DEBUG
209 if(
BASECAMP.IsDebuggerPresent() ) {
210 Variable variable= variables::CampVariable( ALOX, Variables::NO_IDE_LOGGER );
211 bool createIDELogger= variable.IsNotDefined() || (variable.GetBool() == false);
213 if(createIDELogger) {
214 IDELogger= new VStudioLogger(
"IDE_LOGGER");
217 lox->SetVerbosity( IDELogger, Verbosity::Verbose,
"/" );
218 lox->SetVerbosity( IDELogger, Verbosity::Warning, Lox::InternalDomains );
226 lox->SetVerbosity( DebugLogger, Verbosity::Verbose );
234 Box replacements[2]= {
"LOG",
"DEBUG_LOGGER" };
236 if( variable.IsNotDefined() ) {
237 (void) variable.Define();
238 variable.Get<CVVerbosities>().ExportAll=
true;
250 SetALibAssertionPlugin( lox );
261 "Log::RemoveDebugLogger(): no debug logger to remove." )
270 #if defined(_WIN32) && ALIB_DEBUG
304 std::string_view domain,
305 std::string_view msg );
310namespace {
Lox* assertionLox=
nullptr; }
316 if ( pLox ==
nullptr ) {
317 if ( assertionLox ==
nullptr )
321 assertionLox->GetLogableContainer().Add(
"ALoxAssertionPlugin removed "
322 "from Lox {!Q}", assertionLox->GetName() );
324 assertionLox->Release ();
325 assertionLox =
nullptr;
334 assertionLox->GetLogableContainer().Add(
"ALoxAssertionPlugin set to Lox {!Q}.", pLox->
GetName() );
342 assertionLox->Release ();
347 std::string_view domain,
348 std::string_view msg ) {
349 assertionLox->Acquire( ci );
351 auto& logables= assertionLox->GetLogableContainer();
354 auto verbosity= type == 0 ? Verbosity::Error :
355 type == 1 ? Verbosity::Warning :
356 type == 2 ? Verbosity::Info :
361 assertionLox->Entry( dom, verbosity );
362 assertionLox->Release ();
static ALIB_DLL textlogger::TextLogger * DebugLogger
The debug logger created by AddDebugLogger.
static ALIB_DLL void RemoveDebugLogger(Lox *lox)
static ALIB_DLL void AddDebugLogger(Lox *lox)
static ALIB_DLL void SetALibAssertionPlugin(Lox *lox)
static ALIB_DLL textlogger::TextLogger * IDELogger
An (additional) IDE specific logger, that might be created by AddDebugLogger.
This class acts as a container for Loggers and provides a convenient interface to logging.
ALIB_DLL ~Lox()
Destructs a lox.
ALIB_DLL Lox(const NString &name, bool doRegister=true)
detail::LoxImpl * impl
The implementation.
static ALIB_DLL textlogger::TextLogger * CreateConsoleLogger(const NString &name=nullptr)
static constexpr NString InternalDomains
const NString & GetName()
static ALIB_DLL void Register(Lox *lox, lang::ContainerOp operation)
static ALIB_DLL Lox * Get(const NString &name, lang::CreateIfNotExists create=lang::CreateIfNotExists::No)
constexpr bool IsEmpty() const
bool Equals(const TString< TChar > &rhs) const
TSubstring & Trim(const TCString< TChar > &whiteSpaces=CStringConstantsTraits< TChar >::DefaultWhitespaces())
ALIB_DLL bool Define(Priority requestedPriority=Priority::Standard)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ERROR(domain,...)
#define ALIB_LOCK_RECURSIVE_WITH(lock)
#define ALIB_LOCK_WITH(lock)
void(* PLUGIN)(const CallerInfo &ci, int type, std::string_view domain, std::string_view msg)
ContainerOp
Denotes standard container operations.
@ Remove
Denotes removals.
@ Insert
Denotes insertions.
CreateIfNotExists
Denotes whether something should be created if it does not exist.
@ Yes
Create if something does not exist.
void shutdownLoxes()
Internal lox management.
void ALoxAssertionPlugin(const lang::CallerInfo &ci, int type, std::string_view domain, std::string_view msg)
std::string_view const ALOX_ASSERTION_PLUGIN_DOMAIN_PREFIX
@ CONSOLE_LIGHT_COLORS
Denotes configuration variable ALOX/CONSOLE_LIGHT_COLORS used by colorful specializations of class Te...
@ CONSOLE_TYPE
Denotes configuration variable ALOX/CONSOLE_TYPE used by Lox::CreateConsoleLogger.
@ VERBOSITY
Denotes configuration variable ALOX/LOGGERNAME/VERBOSITY_WITH_LOXNAME.
@ DOMAIN_SUBSTITUTION
Denotes configuration variable ALOX/LOXNAME/DOMAIN_SUBSTITUTION used by class Lox.
@ DUMP_STATE_ON_EXIT
Denotes configuration variable ALOX/LOXNAME/DUMP_STATE_ON_EXIT used by class Lox.
@ SPTR_LOX
Denotes configuration variable ALOX/LOXNAME/SOURCE_PATH_TRIM_RULES used by class Lox.
@ PREFIXES
Denotes configuration variable ALOX/LOXNAME/PREFIXES used by class Lox.
ALIB_DLL TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
ALIB_DLL RecursiveLock GLOBAL_ALLOCATOR_LOCK
variables::Variable CampVariable(camp::Camp &camp)
variables::Variable Variable
Type alias in namespace alib.
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class Basecamp.
lox::loggers::AnsiConsoleLogger AnsiConsoleLogger
Type alias in namespace alib.
containers::List< T, MonoAllocator, TRecycling > ListMA
Type alias in namespace alib.
lox::loggers::ConsoleLogger ConsoleLogger
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
lox::ALoxCamp ALOX
The singleton instance of ALib Camp class ALoxCamp.
lox::loggers::WindowsConsoleLogger WindowsConsoleLogger
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
lox::Lox Lox
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
NLocalString< 256 > NString256
Type alias name for TLocalString<nchar,256>.
strings::TSubstring< character > Substring
Type alias in namespace alib.
lox::textlogger::TextLogger TextLogger
Type alias in namespace alib.
static ALIB_DLL void Destruct(LoxImpl *lox)
static ALIB_DLL LoxImpl * Construct(const NString &name)