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