ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
log.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_ALOX_LOG
9#define HPP_ALOX_LOG 1
10
11#if !defined(HPP_ALIB_ALOX)
12# error "ALib sources with ending '.inl' must not be included from outside."
13#endif
14
15namespace alib { namespace lox {
16
17// forward declarations
18class Lox;
19namespace detail
20{
21 class Logger;
22 namespace textlogger
23 {
24 class TextLogger;
25 }
26}
27
29
30// The debug lox singleton
31#if ALOX_DBG_LOG && !defined(ALIB_DOX)
32
33 extern ALIB_API Lox* theDebugLox; // will be created in ALox::bootstrap
34
35#endif
36
37
38
39/** ************************************************************************************************
40 * Holds static objects used for standard debug logging and provides an interface to
41 * create such objects. If compiler symbol #ALOX_DBG_LOG is set to \c 0, this class will be empty.
42 **************************************************************************************************/
43class Log
44{
45 #if ALOX_DBG_LOG
46
47 // #############################################################################################
48 // Public fields
49 // #############################################################################################
50
51 public:
52 /** The debug logger created by AddDebugLogger. */
54
55 /** An (additional) IDE specific logger, that might be created by AddDebugLogger. */
57
58 /** The \alib ReportWriter. This will be created and registered in method
59 * \ref alib::lox::Log::AddDebugLogger "Log::AddDebugLogger" and removed and deleted in
60 * \ref alib::lox::Log::RemoveDebugLogger "Log::RemoveDebugLogger" in the case that
61 * the original \alib \b ReportWriterStdIO is in place.
62 */
64
65 // #############################################################################################
66 // Interface
67 // #############################################################################################
68 public:
69 /** ****************************************************************************************
70 * Returns the default singleton of class \b %Lox used for debug logging.
71 * @return The debug-logging Lox of \alox
72 ******************************************************************************************/
75 {
76 return theDebugLox;
77 }
78
79
80 /** ****************************************************************************************
81 * This method creates an adequate/default debug logger.
82 * It is used by macro \ref Log_AddDebugLogger also automatically invoked
83 * when debug logging is used without the explicit creation and registration of
84 * any other logger.
85 *
86 * Of-course, alternatively to using this method (resp. the macro), a suitable (set of)
87 * debug logger(s) can be created manually. Also, before or after using this method
88 * additional debug loggers may be created.
89 *
90 * In the current version of \alox (future changes are likely), this method does:
91 * - use
92 * \ref alib::lox::Lox::CreateConsoleLogger "Lox::CreateConsoleLogger"
93 * to create the best compatible console logger for the
94 * running platform
95 * - this logger will be added to the debug Lox object with specifying
96 * \c Verbosity::Error for internal domains.
97 * - If under windows, a Visual Studio debug session is running, adds a
98 * \ref alib::lox::loggers::VStudioLogger "VStudioLogger"
99 * in addition to the standard console logger. This can be suppressed using
100 * configuration variable \ref alxcvALOX_NO_IDE_LOGGER.
101 *
102 * The name of the \e Logger created is \c "DEBUG_LOGGER". It will be registered with
103 * the standard \b %Lox used for debug-logging, by setting \e Verbosities
104 * - Verbosity::Verbose for the root domain <c> '/'</c> and
105 * - Verbosity::Warning for internal domains.
106 *
107 * An optionally created second, IDE-specific \e Logger will be named \c "IDE_LOGGER"
108 * and will be registered with the standard \b %Lox used for debug-logging with the same
109 * \e Verbosities as \c "DEBUG_LOGGER" is.
110 *
111 * Finally, this method also invokes #AddALibReportWriter.
112 *
113 * @param lox The lox to add the debug logger(s) to.
114 ******************************************************************************************/
115 ALIB_API static void AddDebugLogger( Lox* lox );
116
117 /** ****************************************************************************************
118 * Removes the \e Logger(s) and which was (were) created by \ref AddDebugLogger.
119 * This method also invokes #RemoveALibReportWriter.
120 *
121 * @param lox The lox to remove the debug logger(s) from.
122 ******************************************************************************************/
123 ALIB_API static void RemoveDebugLogger( Lox* lox );
124
125 /** ****************************************************************************************
126 * In the case that the original \alib \b ReportWriterStdIO is still in place,
127 * \ref alib::lang::Report::PushWriter "Report::PushWriter" is invoked to provide a
128 * ReportWriter of type
129 * \ref alib::lox::ALoxReportWriter "ALoxReportWriter".
130 *
131 * \note
132 * This method is effective only with debug builds. Usually it is invoked indirectly by
133 * using method #AddDebugLogger. Applications that do not use that method (e.g. because
134 * they are using release logging exclusively), should invoke this method on bootstrap
135 * providing their (release) lox.
136 * In this case, the \e Verbosity of the internal domain used by class
137 * \ref alib::lox::ALoxReportWriter "ALoxReportWriter" has to be set for the
138 * the logger(s) in given \p{lox} in question.
139 *
140 * @param lox The lox that the
141 * \ref alib::lox::ALoxReportWriter "ALoxReportWriter" created will be using.
142 ******************************************************************************************/
143 ALIB_API static void AddALibReportWriter( Lox* lox );
144
145 /** ****************************************************************************************
146 * Removes the report writer created with #AddALibReportWriter.
147 ******************************************************************************************/
148 ALIB_API static void RemoveALibReportWriter();
149
150 #endif // ALOX_DBG_LOG
151
152}; // LOG
153
154
155} // namespace alib[::lox]
156
157/// Type alias in namespace \b alib.
159
160} // namespace [alib]
161
162#endif // HPP_ALOX_LOG
static ALIB_API void AddDebugLogger(Lox *lox)
Definition log.cpp:50
static ALIB_API ALoxReportWriter * DebugReportWriter
Definition log.inl:63
static ALIB_API void RemoveDebugLogger(Lox *lox)
Definition log.cpp:95
static ALIB_API detail::textlogger::TextLogger * DebugLogger
Definition log.inl:53
static ALIB_API detail::textlogger::TextLogger * IDELogger
Definition log.inl:56
static ALIB_API void RemoveALibReportWriter()
Definition log.cpp:138
static ALIB_FORCE_INLINE Lox * Get()
Definition log.inl:74
static ALIB_API void AddALibReportWriter(Lox *lox)
Definition log.cpp:128
#define ALIB_FORCE_INLINE
Definition alib.hpp:549
#define ALIB_API
Definition alib.hpp:538
Definition alib.cpp:57
lox::ALoxReportWriter ALoxReportWriter
Type alias in namespace alib.
lox::detail::textlogger::TextLogger TextLogger
Type alias in namespace alib.
lox::detail::Logger Logger
Type alias in namespace alib.
Definition logger.hpp:199
lox::Lox Lox
Type alias in namespace alib.
Definition lox.inl:1492