ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alox.prepro.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_ALOX_PP
9#define HPP_ALIB_ALOX_PP
10#pragma once
11#ifndef INL_ALIB
12# include "alib/alib.inl"
13#endif
14
15// #################################################################################################
16// Symbols introduced by module ALib.ALox
17// #################################################################################################
18
19// ALOX_DBG_LOG, ALOX_REL_LOG, ALOX_DBG_LOG_CI, ALOX_REL_LOG_CI
20#if !ALIB_ALOX
21# define ALOX_DBG_LOG 0
22# define ALOX_DBG_LOG_CI 0
23# define ALOX_REL_LOG 0
24# define ALOX_REL_LOG_CI 0
25#else
26# if !defined(ALOX_DBG_LOG)
27# define ALOX_DBG_LOG ALIB_DEBUG
28# endif
29# if !defined(ALOX_DBG_LOG_CI)
30# define ALOX_DBG_LOG_CI ALIB_DEBUG
31# endif
32
33# if !defined(ALOX_REL_LOG)
34# define ALOX_REL_LOG 1
35# endif
36# if !defined(ALOX_REL_LOG_CI)
37# define ALOX_REL_LOG_CI 0
38# endif
39#endif
40
41#if ALIB_ALOX
42
43// Macros to access the Lox instance
44#if !defined(LOG_LOX)
45# define LOG_LOX (*alib::lox::Log::Get())
46#endif
47
48// Macros for setting the source code info before executing a log
49#ifdef ALOX_DBG_LOG_CI
50# define LOG_CI ALIB_CALLER
51#else
52 #if ALIB_EXT_LIB_THREADS_AVAILABLE
53 #define LOG_CI {nullptr,0,nullptr,::std::thread::id(), nullptr}
54 #else
55 #define LOG_CI {nullptr,0,nullptr,nullptr}
56 #endif
57#endif
58
59#ifdef ALOX_REL_LOG_CI
60# define LOX_CI ALIB_CALLER
61#else
62 #if ALIB_EXT_LIB_THREADS_AVAILABLE
63 #define LOG_CI {nullptr,0,nullptr,::std::thread::id(), nullptr}
64 #else
65 #define LOG_CI {nullptr,0,nullptr,nullptr}
66 #endif
67#endif
68
69#define LOG_ACQUIRE { alib::lox::Lox& _log= LOG_LOX; _log.Acquire( LOG_CI );
70#define LOG_RELEASE _log.Release(); }
71#define LOX_ACQUIRE { alib::lox::Lox& _lox= LOX_LOX; _lox.Acquire( LOX_CI );
72#define LOX_RELEASE _lox.Release(); }
73
74// Debug logging macros
75#if ALOX_DBG_LOG
76# define Log_Prune( ... ) __VA_ARGS__
77#else
78# define Log_Prune( ... )
79#endif
80
81#define Log_SetSourcePathTrimRule(...) { Log_Prune( LOG_ACQUIRE _log.SetSourcePathTrimRule( __VA_ARGS__ ); LOG_RELEASE ) }
82#define Log_ClearSourcePathTrimRules(...) { Log_Prune( LOG_ACQUIRE _log.ClearSourcePathTrimRules( __VA_ARGS__ ); LOG_RELEASE ) }
83#define Log_AddDebugLogger() { Log_Prune( LOG_ACQUIRE alib::Log::AddDebugLogger ( &_log ); LOG_RELEASE ) }
84#define Log_RemoveDebugLogger() { Log_Prune( LOG_ACQUIRE alib::Log::RemoveDebugLogger( &_log ); LOG_RELEASE ) }
85#define Log_GetLogger( identifier, name ) Log_Prune( alib::lox::detail::Logger* identifier; \
86 LOG_ACQUIRE identifier= _log.GetLogger( name ); LOG_RELEASE )
87#define Log_RemoveLogger( logger) { Log_Prune( LOG_ACQUIRE _log.RemoveLogger ( logger ); LOG_RELEASE ) }
88#define Log_SetDomain(...) { Log_Prune( LOG_ACQUIRE _log.SetDomain ( __VA_ARGS__ ); LOG_RELEASE ) }
89#define Log_RemoveThreadDomain(...) { Log_Prune( LOG_ACQUIRE _log.RemoveThreadDomain( __VA_ARGS__ ); LOG_RELEASE ) }
90#define Log_SetDomainSubstitutionRule(...) { Log_Prune( LOG_ACQUIRE _log.SetDomainSubstitutionRule( __VA_ARGS__); LOG_RELEASE ) }
91#define Log_SetVerbosity(...) { Log_Prune( LOG_ACQUIRE _log.SetVerbosity ( __VA_ARGS__ ); LOG_RELEASE ) }
92#define Log_SetStartTime( ... ) { Log_Prune( LOG_ACQUIRE _log.SetStartTime ( __VA_ARGS__ ); LOG_RELEASE ) }
93#define Log_MapThreadName(...) { Log_Prune( LOG_ACQUIRE _log.MapThreadName( __VA_ARGS__ ); LOG_RELEASE ) }
94#define Log_LogState(...) { Log_Prune( LOG_ACQUIRE _log.State ( __VA_ARGS__ ); LOG_RELEASE ) }
95#define Log_Verbose(...) { Log_Prune( LOG_ACQUIRE _log.Verbose ( __VA_ARGS__ ); LOG_RELEASE ) }
96#define Log_Info(...) { Log_Prune( LOG_ACQUIRE _log.Info ( __VA_ARGS__ ); LOG_RELEASE ) }
97#define Log_Warning(...) { Log_Prune( LOG_ACQUIRE _log.Warning ( __VA_ARGS__ ); LOG_RELEASE ) }
98#define Log_Error(...) { Log_Prune( LOG_ACQUIRE _log.Error ( __VA_ARGS__ ); LOG_RELEASE ) }
99#define Log_Assert(...) { Log_Prune( LOG_ACQUIRE _log.Assert ( __VA_ARGS__ ); LOG_RELEASE ) }
100#define Log_If(...) { Log_Prune( LOG_ACQUIRE _log.If ( __VA_ARGS__ ); LOG_RELEASE ) }
101#define Log_Once(...) { Log_Prune( LOG_ACQUIRE _log.Once ( __VA_ARGS__ ); LOG_RELEASE ) }
102#define Log_Entry(...) { Log_Prune( LOG_ACQUIRE _log.Entry ( __VA_ARGS__ ); LOG_RELEASE ) }
103#define Log_SetPrefix(...) { Log_Prune( LOG_ACQUIRE _log.SetPrefix ( __VA_ARGS__ ); LOG_RELEASE ) }
104#define Log_Store(...) { Log_Prune( LOG_ACQUIRE _log.Store ( __VA_ARGS__ ); LOG_RELEASE ) }
105#define Log_Retrieve(data,...) Log_Prune( Box data; LOG_ACQUIRE data= _log.Retrieve( __VA_ARGS__ ); LOG_RELEASE )
106#define Log_IsActive(result, ...) Log_Prune( LOG_ACQUIRE result= _log.IsActive( __VA_ARGS__ ); LOG_RELEASE )
107#define Log_Exception(...) { Log_Prune( alib::lox::LogTools::Exception( LOG_LOX, __VA_ARGS__ ); ) }
108
109
110// Release logging macros
111#if ALOX_REL_LOG
112# define Lox_Prune( ... ) __VA_ARGS__
113#else
114# define Lox_Prune( ... )
115#endif
116
117#define Lox_SetSourcePathTrimRule(...) { Lox_Prune( LOX_ACQUIRE _lox.SetSourcePathTrimRule( __VA_ARGS__ ); LOX_RELEASE ) }
118#define Lox_ClearSourcePathTrimRules(...) { Lox_Prune( LOX_ACQUIRE _lox.ClearSourcePathTrimRules( __VA_ARGS__ ); LOX_RELEASE ) }
119#define Lox_GetLogger( identifier, name ) Lox_Prune( alib::lox::detail::Logger* identifier; LOX_ACQUIRE identifier= _lox.GetLogger ( name ); LOX_RELEASE )
120#define Lox_RemoveLogger( logger ) { Lox_Prune( LOX_ACQUIRE _lox.RemoveLogger ( logger ); LOX_RELEASE ) }
121#define Lox_SetDomain(...) { Lox_Prune( LOX_ACQUIRE _lox.SetDomain (__VA_ARGS__); LOX_RELEASE ) }
122#define Lox_RemoveThreadDomain(...) { Lox_Prune( LOX_ACQUIRE _lox.RemoveThreadDomain( __VA_ARGS__ ); LOX_RELEASE ) }
123#define Lox_SetDomainSubstitutionRule(...) { Lox_Prune( LOX_ACQUIRE _lox.SetDomainSubstitutionRule( __VA_ARGS__ );LOX_RELEASE ) }
124#define Lox_SetVerbosity(...) { Lox_Prune( LOX_ACQUIRE _lox.SetVerbosity ( __VA_ARGS__ ); LOX_RELEASE ) }
125#define Lox_SetStartTime( ... ) { Lox_Prune( LOX_ACQUIRE _lox.SetStartTime ( __VA_ARGS__ ); LOX_RELEASE ) }
126#define Lox_MapThreadName(...) { Lox_Prune( LOX_ACQUIRE _lox.MapThreadName( __VA_ARGS__ ); LOX_RELEASE ) }
127#define Lox_LogState(...) { Lox_Prune( LOX_ACQUIRE _lox.State ( __VA_ARGS__ ); LOX_RELEASE ) }
128#define Lox_Verbose(...) { Lox_Prune( LOX_ACQUIRE _lox.Verbose ( __VA_ARGS__ ); LOX_RELEASE ) }
129#define Lox_Info(...) { Lox_Prune( LOX_ACQUIRE _lox.Info ( __VA_ARGS__ ); LOX_RELEASE ) }
130#define Lox_Warning(...) { Lox_Prune( LOX_ACQUIRE _lox.Warning ( __VA_ARGS__ ); LOX_RELEASE ) }
131#define Lox_Error(...) { Lox_Prune( LOX_ACQUIRE _lox.Error ( __VA_ARGS__ ); LOX_RELEASE ) }
132#define Lox_Assert(...) { Lox_Prune( LOX_ACQUIRE _lox.Assert ( __VA_ARGS__); LOX_RELEASE ) }
133#define Lox_If(...) { Lox_Prune( LOX_ACQUIRE _lox.If ( __VA_ARGS__); LOX_RELEASE ) }
134#define Lox_Once(...) { Lox_Prune( LOX_ACQUIRE _lox.Once ( __VA_ARGS__ ); LOX_RELEASE ) }
135#define Lox_Entry(...) { Lox_Prune( LOX_ACQUIRE _lox.Entry ( __VA_ARGS__ ); LOX_RELEASE ) }
136#define Lox_Store(...) { Lox_Prune( LOX_ACQUIRE _lox.Store ( __VA_ARGS__ ); LOX_RELEASE ) }
137#define Lox_Retrieve(data,...) { Lox_Prune( LOX_ACQUIRE LogData* data= _lox.Retrieve( __VA_ARGS__ ); LOX_RELEASE ) }
138#define Lox_SetPrefix(...) { Lox_Prune( LOX_ACQUIRE _lox.SetPrefix ( __VA_ARGS__ ); LOX_RELEASE ) }
139#define Lox_IsActive(result, ...) { Lox_Prune( LOX_ACQUIRE result= _lox.IsActive( __VA_ARGS__ ); LOX_RELEASE ) }
140#define Lox_Exception(...) { Lox_Prune( alib::lox::LogTools::Exception( LOX_LOX, __VA_ARGS__ ); ) }
141
142// #############################################################################################
143// If ALox not included in the build, set all macros to empty
144// #############################################################################################
145#else // ALIB_ALOX
146# define Log_Prune( ... )
147# define Log_SetSourcePathTrimRule(...)
148# define Log_ClearSourcePathTrimRules(...)
149# define Log_AddDebugLogger()
150# define Log_RemoveDebugLogger()
151# define Log_GetLogger( identifier, name )
152# define Log_RemoveLogger( logger)
153# define Log_SetDomain(...)
154# define Log_RemoveThreadDomain(...)
155# define Log_SetDomainSubstitutionRule(...)
156# define Log_SetVerbosity(...)
157# define Log_SetStartTime( ... )
158# define Log_MapThreadName(...)
159# define Log_LogState(...)
160# define Log_Verbose(...)
161# define Log_Info(...)
162# define Log_Warning(...)
163# define Log_Error(...)
164# define Log_Assert(...)
165# define Log_If(...)
166# define Log_Once(...)
167# define Log_Entry(...)
168# define Log_SetPrefix(...)
169# define Log_Store(...)
170# define Log_Retrieve(data,...)
171# define Log_Exception(...)
172
173# define Lox_Prune( ... )
174# define Lox_SetSourcePathTrimRule(...)
175# define Lox_ClearSourcePathTrimRules(...)
176# define Lox_GetLogger( identifier, name )
177# define Lox_RemoveLogger( logger )
178# define Lox_SetDomain(...)
179# define Lox_RemoveThreadDomain(...)
180# define Lox_SetDomainSubstitutionRule(...)
181# define Lox_SetVerbosity(...)
182# define Lox_SetStartTime( ... )
183# define Lox_MapThreadName(...)
184# define Lox_LogState(...)
185# define Lox_Verbose(...)
186# define Lox_Info(...)
187# define Lox_Warning(...)
188# define Lox_Error(...)
189# define Lox_Assert(...)
190# define Lox_If(...)
191# define Lox_Once(...)
192# define Lox_Entry(...)
193# define Lox_Store(...)
194# define Lox_Retrieve(data,...)
195# define Lox_SetPrefix(...)
196# define Lox_Exception(...)
197
198#endif //ALIB_ALOX
199#endif // HPP_ALIB_ALOX_PP
200
201
202