ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
macros.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_alox of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_LOX_MACROS
9#define HPP_ALIB_LOX_MACROS 1
10#pragma once
11#if !defined(HPP_ALIB_ALOX)
12# error "ALib sources with ending '.inl' must not be included from outside."
13#endif
14
15// #################################################################################################
16// Macros to access the Lox instance
17// #################################################################################################
18#if !defined(LOG_LOX)
19# define LOG_LOX (*alib::lox::Log::Get())
20#endif
21
22// #################################################################################################
23// Macros for setting the source code info before executing a log
24// #################################################################################################
25#ifdef ALOX_DBG_LOG_CI
26# define LOG_CI ALIB_CALLER
27#else
28 #if ALIB_EXT_LIB_THREADS_AVAILABLE
29 #define LOG_CI {nullptr,0,nullptr,::std::thread::id(), nullptr}
30 #else
31 #define LOG_CI {nullptr,0,nullptr,nullptr}
32 #endif
33#endif
34
35#ifdef ALOX_REL_LOG_CI
36# define LOX_CI ALIB_CALLER
37#else
38 #if ALIB_EXT_LIB_THREADS_AVAILABLE
39 #define LOG_CI {nullptr,0,nullptr,::std::thread::id(), nullptr}
40 #else
41 #define LOG_CI {nullptr,0,nullptr,nullptr}
42 #endif
43#endif
44
45#define LOG_ACQUIRE { alib::lox::Lox& _log= LOG_LOX; _log.Acquire( LOG_CI );
46#define LOG_RELEASE _log.Release(); }
47#define LOX_ACQUIRE { alib::lox::Lox& _lox= LOX_LOX; _lox.Acquire( LOX_CI );
48#define LOX_RELEASE _lox.Release(); }
49
50
51// #################################################################################################
52// Debug logging macros
53// #################################################################################################
54#if ALOX_DBG_LOG
55# define Log_Prune( ... ) __VA_ARGS__
56#else
57# define Log_Prune( ... )
58#endif
59
60#define Log_SetSourcePathTrimRule(...) { Log_Prune( LOG_ACQUIRE _log.SetSourcePathTrimRule( __VA_ARGS__ ); LOG_RELEASE ) }
61#define Log_ClearSourcePathTrimRules(...) { Log_Prune( LOG_ACQUIRE _log.ClearSourcePathTrimRules( __VA_ARGS__ ); LOG_RELEASE ) }
62#define Log_AddDebugLogger() { Log_Prune( LOG_ACQUIRE alib::Log::AddDebugLogger ( &_log ); LOG_RELEASE ) }
63#define Log_RemoveDebugLogger() { Log_Prune( LOG_ACQUIRE alib::Log::RemoveDebugLogger( &_log ); LOG_RELEASE ) }
64#define Log_GetLogger( identifier, name ) Log_Prune( alib::lox::detail::Logger* identifier; \
65 LOG_ACQUIRE identifier= _log.GetLogger( name ); LOG_RELEASE )
66#define Log_RemoveLogger( logger) { Log_Prune( LOG_ACQUIRE _log.RemoveLogger ( logger ); LOG_RELEASE ) }
67#define Log_SetDomain(...) { Log_Prune( LOG_ACQUIRE _log.SetDomain ( __VA_ARGS__ ); LOG_RELEASE ) }
68#define Log_RemoveThreadDomain(...) { Log_Prune( LOG_ACQUIRE _log.RemoveThreadDomain( __VA_ARGS__ ); LOG_RELEASE ) }
69#define Log_SetDomainSubstitutionRule(...) { Log_Prune( LOG_ACQUIRE _log.SetDomainSubstitutionRule( __VA_ARGS__); LOG_RELEASE ) }
70#define Log_SetVerbosity(...) { Log_Prune( LOG_ACQUIRE _log.SetVerbosity ( __VA_ARGS__ ); LOG_RELEASE ) }
71#define Log_SetStartTime( ... ) { Log_Prune( LOG_ACQUIRE _log.SetStartTime ( __VA_ARGS__ ); LOG_RELEASE ) }
72#define Log_MapThreadName(...) { Log_Prune( LOG_ACQUIRE _log.MapThreadName( __VA_ARGS__ ); LOG_RELEASE ) }
73#define Log_LogState(...) { Log_Prune( LOG_ACQUIRE _log.State ( __VA_ARGS__ ); LOG_RELEASE ) }
74#define Log_Verbose(...) { Log_Prune( LOG_ACQUIRE _log.Verbose ( __VA_ARGS__ ); LOG_RELEASE ) }
75#define Log_Info(...) { Log_Prune( LOG_ACQUIRE _log.Info ( __VA_ARGS__ ); LOG_RELEASE ) }
76#define Log_Warning(...) { Log_Prune( LOG_ACQUIRE _log.Warning ( __VA_ARGS__ ); LOG_RELEASE ) }
77#define Log_Error(...) { Log_Prune( LOG_ACQUIRE _log.Error ( __VA_ARGS__ ); LOG_RELEASE ) }
78#define Log_Assert(...) { Log_Prune( LOG_ACQUIRE _log.Assert ( __VA_ARGS__ ); LOG_RELEASE ) }
79#define Log_If(...) { Log_Prune( LOG_ACQUIRE _log.If ( __VA_ARGS__ ); LOG_RELEASE ) }
80#define Log_Once(...) { Log_Prune( LOG_ACQUIRE _log.Once ( __VA_ARGS__ ); LOG_RELEASE ) }
81#define Log_Entry(...) { Log_Prune( LOG_ACQUIRE _log.Entry ( __VA_ARGS__ ); LOG_RELEASE ) }
82#define Log_SetPrefix(...) { Log_Prune( LOG_ACQUIRE _log.SetPrefix ( __VA_ARGS__ ); LOG_RELEASE ) }
83#define Log_Store(...) { Log_Prune( LOG_ACQUIRE _log.Store ( __VA_ARGS__ ); LOG_RELEASE ) }
84#define Log_Retrieve(data,...) Log_Prune( Box data; LOG_ACQUIRE data= _log.Retrieve( __VA_ARGS__ ); LOG_RELEASE )
85#define Log_IsActive(result, ...) Log_Prune( LOG_ACQUIRE result= _log.IsActive( __VA_ARGS__ ); LOG_RELEASE )
86#define Log_Exception(...) { Log_Prune( alib::lox::LogTools::Exception( LOG_LOX, __VA_ARGS__ ); ) }
87
88
89
90// #################################################################################################
91// Release logging macros
92// #################################################################################################
93#if ALOX_REL_LOG
94# define Lox_Prune( ... ) __VA_ARGS__
95#else
96# define Lox_Prune( ... )
97#endif
98
99#define Lox_SetSourcePathTrimRule(...) { Lox_Prune( LOX_ACQUIRE _lox.SetSourcePathTrimRule( __VA_ARGS__ ); LOX_RELEASE ) }
100#define Lox_ClearSourcePathTrimRules(...) { Lox_Prune( LOX_ACQUIRE _lox.ClearSourcePathTrimRules( __VA_ARGS__ ); LOX_RELEASE ) }
101#define Lox_GetLogger( identifier, name ) Lox_Prune( alib::lox::detail::Logger* identifier; LOX_ACQUIRE identifier= _lox.GetLogger ( name ); LOX_RELEASE )
102#define Lox_RemoveLogger( logger ) { Lox_Prune( LOX_ACQUIRE _lox.RemoveLogger ( logger ); LOX_RELEASE ) }
103#define Lox_SetDomain(...) { Lox_Prune( LOX_ACQUIRE _lox.SetDomain (__VA_ARGS__); LOX_RELEASE ) }
104#define Lox_RemoveThreadDomain(...) { Lox_Prune( LOX_ACQUIRE _lox.RemoveThreadDomain( __VA_ARGS__ ); LOX_RELEASE ) }
105#define Lox_SetDomainSubstitutionRule(...) { Lox_Prune( LOX_ACQUIRE _lox.SetDomainSubstitutionRule( __VA_ARGS__ );LOX_RELEASE ) }
106#define Lox_SetVerbosity(...) { Lox_Prune( LOX_ACQUIRE _lox.SetVerbosity ( __VA_ARGS__ ); LOX_RELEASE ) }
107#define Lox_SetStartTime( ... ) { Lox_Prune( LOX_ACQUIRE _lox.SetStartTime ( __VA_ARGS__ ); LOX_RELEASE ) }
108#define Lox_MapThreadName(...) { Lox_Prune( LOX_ACQUIRE _lox.MapThreadName( __VA_ARGS__ ); LOX_RELEASE ) }
109#define Lox_LogState(...) { Lox_Prune( LOX_ACQUIRE _lox.State ( __VA_ARGS__ ); LOX_RELEASE ) }
110#define Lox_Verbose(...) { Lox_Prune( LOX_ACQUIRE _lox.Verbose ( __VA_ARGS__ ); LOX_RELEASE ) }
111#define Lox_Info(...) { Lox_Prune( LOX_ACQUIRE _lox.Info ( __VA_ARGS__ ); LOX_RELEASE ) }
112#define Lox_Warning(...) { Lox_Prune( LOX_ACQUIRE _lox.Warning ( __VA_ARGS__ ); LOX_RELEASE ) }
113#define Lox_Error(...) { Lox_Prune( LOX_ACQUIRE _lox.Error ( __VA_ARGS__ ); LOX_RELEASE ) }
114#define Lox_Assert(...) { Lox_Prune( LOX_ACQUIRE _lox.Assert ( __VA_ARGS__); LOX_RELEASE ) }
115#define Lox_If(...) { Lox_Prune( LOX_ACQUIRE _lox.If ( __VA_ARGS__); LOX_RELEASE ) }
116#define Lox_Once(...) { Lox_Prune( LOX_ACQUIRE _lox.Once ( __VA_ARGS__ ); LOX_RELEASE ) }
117#define Lox_Entry(...) { Lox_Prune( LOX_ACQUIRE _lox.Entry ( __VA_ARGS__ ); LOX_RELEASE ) }
118#define Lox_Store(...) { Lox_Prune( LOX_ACQUIRE _lox.Store ( __VA_ARGS__ ); LOX_RELEASE ) }
119#define Lox_Retrieve(data,...) { Lox_Prune( LOX_ACQUIRE LogData* data= _lox.Retrieve( __VA_ARGS__ ); LOX_RELEASE ) }
120#define Lox_SetPrefix(...) { Lox_Prune( LOX_ACQUIRE _lox.SetPrefix ( __VA_ARGS__ ); LOX_RELEASE ) }
121#define Lox_IsActive(result, ...) { Lox_Prune( LOX_ACQUIRE result= _lox.IsActive( __VA_ARGS__ ); LOX_RELEASE ) }
122#define Lox_Exception(...) { Lox_Prune( alib::lox::LogTools::Exception( LOX_LOX, __VA_ARGS__ ); ) }
123
124#endif // HPP_ALIB_LOX_MACROS
125