ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
macros.inl File Reference

Description:


This header file is part of module ALox of the ALib C++ Library .

© 2013-2024 A-Worx GmbH, Germany. Published under Boost Software License.

Definition in file macros.inl.

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

ALox Low level Macros

The preprocessor macros listed here are the foundation for debug logging and release logging macros introduced below.

Developers that use ALox in standard use cases do not need to know and use the macros listed here.

#define LOG_ACQUIRE   { alib::lox::Lox& _log= LOG_LOX; _log.Acquire( LOG_CI );
 
#define LOG_CI   ALIB_CALLER
 
#define LOG_LOX   (*alib::lox::Log::Get())
 
#define LOG_RELEASE   _log.Release(); }
 
#define LOX_ACQUIRE   { alib::lox::Lox& _lox= LOX_LOX; _lox.Acquire( LOX_CI );
 
#define LOX_CI   ALIB_CALLER
 
#define LOX_RELEASE   _lox.Release(); }
 
ALox Macros For Debug Logging

The macros listed here, are provided to place debug Log Statements within source code using module ALox . Besides that, macros controlling and setting preferences for ALox exists.

The exclusive use of these macros should be sufficient to support most of common debug logging statements with ALox . Should some functionality be not available easily with using the macros, of-course, the normal C++ API of ALox can be used in parallel to using the macros. For proper pruning of code that is using the C++ API, such code has to be enclosed by

#if ALOX_DBG_LOG
   ...
   ...
#endif

lines, or embedded in macro Log_Prune.

Note
To be clear: When using the macros, the #if / #endif statements are not needed!

All macro names are prefixed "Log_". This implies that they are macros to implement debug logging. In contrast to this, a set of similar macros exists for release logging (see release logging macros). Those are prefixed "Lox_". (The choice of the prefixes Log_ and Lox provide maximum source code compatibility of ALox for C++ log lines in comparison to ALox for C# and ALox for Java.

Most macros make use of the macro LOG_LOX, which references a singleton object of class Lox that is used for all debug logging. This singleton concept covers most uses cases for debug logging. If more flexibility is wanted, then either macro LOG_LOX might be changed for different compilation units or the ALox for C++ API might be used instead of the macros listed here.

Note
The Scope Domain mechanism of ALox , as well as other ALox functionality which relies on Scopes use the information provided by ALib macro ALIB_CALLER. Changing this macro, might cause these mechanism to fail.
#define Log_AddDebugLogger()   Log_Prune( LOG_ACQUIRE alib::Log::AddDebugLogger ( &_log ); LOG_RELEASE )
 
#define Log_Assert(...)   Log_Prune( LOG_ACQUIRE _log.Assert ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_ClearSourcePathTrimRules(...)   Log_Prune( LOG_ACQUIRE _log.ClearSourcePathTrimRules( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Entry(...)   Log_Prune( LOG_ACQUIRE _log.Entry ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Error(...)   Log_Prune( LOG_ACQUIRE _log.Error ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Exception(...)   Log_Prune( alib::lox::LogTools::Exception( LOG_LOX, __VA_ARGS__ ); )
 
#define Log_GetLogger(identifier, name)
 
#define Log_If(...)   Log_Prune( LOG_ACQUIRE _log.If ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Info(...)   Log_Prune( LOG_ACQUIRE _log.Info ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_IsActive(result, ...)   Log_Prune( LOG_ACQUIRE result= _log.IsActive( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_LogState(...)   Log_Prune( LOG_ACQUIRE _log.State ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_MapThreadName(...)   Log_Prune( LOG_ACQUIRE _log.MapThreadName( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Once(...)   Log_Prune( LOG_ACQUIRE _log.Once ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Prune(...)   __VA_ARGS__
 
#define Log_RemoveDebugLogger()   Log_Prune( LOG_ACQUIRE alib::Log::RemoveDebugLogger( &_log ); LOG_RELEASE )
 
#define Log_RemoveLogger(logger)   Log_Prune( LOG_ACQUIRE _log.RemoveLogger ( logger ); LOG_RELEASE )
 
#define Log_RemoveThreadDomain(...)   Log_Prune( LOG_ACQUIRE _log.RemoveThreadDomain( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Retrieve(data, ...)   Log_Prune( Box data; LOG_ACQUIRE data= _log.Retrieve( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_SetDomain(...)   Log_Prune( LOG_ACQUIRE _log.SetDomain ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_SetDomainSubstitutionRule(...)   Log_Prune( LOG_ACQUIRE _log.SetDomainSubstitutionRule( __VA_ARGS__); LOG_RELEASE )
 
#define Log_SetPrefix(...)   Log_Prune( LOG_ACQUIRE _log.SetPrefix ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_SetSourcePathTrimRule(...)   Log_Prune( LOG_ACQUIRE _log.SetSourcePathTrimRule( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_SetStartTime(...)   Log_Prune( LOG_ACQUIRE _log.SetStartTime ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_SetVerbosity(...)   Log_Prune( LOG_ACQUIRE _log.SetVerbosity ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Store(...)   Log_Prune( LOG_ACQUIRE _log.Store ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Verbose(...)   Log_Prune( LOG_ACQUIRE _log.Verbose ( __VA_ARGS__ ); LOG_RELEASE )
 
#define Log_Warning(...)   Log_Prune( LOG_ACQUIRE _log.Warning ( __VA_ARGS__ ); LOG_RELEASE )
 
ALox Macros For Release Logging

The macros listed here, are provided to place release Log Statements within source code using module ALox . Besides that, macros controlling and setting preferences for ALox exists.

The exclusive use of these macros should be sufficient to support most of common release logging statements with ALox . Should some functionality be not available easily using the macros, of-course, the normal C++ API of ALox can be used in parallel to using the macros. Code that is using the C++ API might be enclosed by preprocessor directives

#if ALOX_REL_LOG
   ...
   ...
#endif

to remove them when compiling a release version of the software unit with pruned release log macros. Alternatively, such code might be embedded in macro Lox_Prune. (Pruning of release logging can be enabled by defining compiler symbol ALOX_REL_LOG to 0 and could be useful in certain situations.)

Prior to using the macros, each code entity has to set the preprocessor macro LOX_LOX This can be done in a general header file of the software, (e.g. the same that exposes the release-Lox object to that source), or, in more complex scenarios with more than one release-Lox object, at any other appropriate source location.

All macro names are prefixed with the term Lox_. This implies that they are macros to implement release logging. In contrast to this, a set of similar macros exists for debug logging (see debug logging macros). Those are prefixed Log_.

Note
The choice of the prefixes Log_ and Lox_ was made to provide maximum source code compatibility of ALox for C++ log lines in comparison to other ALox implementations in other programming languages, which provide a class Log as a kind of 'mirror' class of class Lox. Invocations to class Log get pruned in these languages.

Most macros make use of the macro LOX_LOX, which references a singleton object of class Lox that is used for all release logging. This singleton concept covers most uses cases for release logging. If more flexibility is wanted, then either the macro LOX_LOX might be changed for different compilation units or the ALox C++ API might be used instead of the macros listed here.

#define Lox_Assert(...)   Lox_Prune( LOX_ACQUIRE _lox.Assert ( __VA_ARGS__); LOX_RELEASE )
 
#define Lox_ClearSourcePathTrimRules(...)   Lox_Prune( LOX_ACQUIRE _lox.ClearSourcePathTrimRules( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Entry(...)   Lox_Prune( LOX_ACQUIRE _lox.Entry ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Error(...)   Lox_Prune( LOX_ACQUIRE _lox.Error ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Exception(...)   Lox_Prune( alib::lox::LogTools::Exception( LOX_LOX, __VA_ARGS__ ); )
 
#define Lox_GetLogger(identifier, name)   Lox_Prune( alib::lox::detail::Logger* identifier; LOX_ACQUIRE identifier= _lox.GetLogger ( name ); LOX_RELEASE )
 
#define Lox_If(...)   Lox_Prune( LOX_ACQUIRE _lox.If ( __VA_ARGS__); LOX_RELEASE )
 
#define Lox_Info(...)   Lox_Prune( LOX_ACQUIRE _lox.Info ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_IsActive(result, ...)   Lox_Prune( LOX_ACQUIRE result= _lox.IsActive( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_LogState(...)   Lox_Prune( LOX_ACQUIRE _lox.State ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_MapThreadName(...)   Lox_Prune( LOX_ACQUIRE _lox.MapThreadName( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Once(...)   Lox_Prune( LOX_ACQUIRE _lox.Once ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Prune(...)   __VA_ARGS__
 
#define Lox_RemoveLogger(logger)   Lox_Prune( LOX_ACQUIRE _lox.RemoveLogger ( logger ); LOX_RELEASE )
 
#define Lox_RemoveThreadDomain(...)   Lox_Prune( LOX_ACQUIRE _lox.RemoveThreadDomain( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Retrieve(data, ...)   Lox_Prune( LOX_ACQUIRE LogData* data= _lox.Retrieve( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_SetDomain(...)   Lox_Prune( LOX_ACQUIRE _lox.SetDomain (__VA_ARGS__); LOX_RELEASE )
 
#define Lox_SetDomainSubstitutionRule(...)   Lox_Prune( LOX_ACQUIRE _lox.SetDomainSubstitutionRule( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_SetPrefix(...)   Lox_Prune( LOX_ACQUIRE _lox.SetPrefix ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_SetSourcePathTrimRule(...)   Lox_Prune( LOX_ACQUIRE _lox.SetSourcePathTrimRule( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_SetStartTime(...)   Lox_Prune( LOX_ACQUIRE _lox.SetStartTime ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_SetVerbosity(...)   Lox_Prune( LOX_ACQUIRE _lox.SetVerbosity ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Store(...)   Lox_Prune( LOX_ACQUIRE _lox.Store ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Verbose(...)   Lox_Prune( LOX_ACQUIRE _lox.Verbose ( __VA_ARGS__ ); LOX_RELEASE )
 
#define Lox_Warning(...)   Lox_Prune( LOX_ACQUIRE _lox.Warning ( __VA_ARGS__ ); LOX_RELEASE )