ALib C++ Library
Library Version: 2510 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-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace lox {
9
10// forward declarations
11class Lox;
12#if !ALIB_C20_MODULES
13namespace detail { class Logger; }
14namespace textlogger { class TextLogger; }
15#endif
16
17// The debug lox singleton
18#if ALOX_DBG_LOG
19 /// The debug-lox instance. This object will be created in method
20 /// \alib{lox;ALoxCamp::Bootstrap} and deleted with \alib{lox;ALoxCamp::Shutdown}.
21 extern ALIB_DLL Lox* DEBUG_LOX;
22#endif
23#if ALIB_DEBUG
24 /// The domain-prefix used with plug-in function \alib{lox;ALoxAssertionPlugin}.
25 /// The given assertion domain will be appended to this name, separated by the domain
26 /// separation character <c>'/'</c>.<br>
27 /// Defaults to <c>"ALIB"</c>.
28 ALIB_DLL extern std::string_view const ALOX_ASSERTION_PLUGIN_DOMAIN_PREFIX;
29#endif
30
31//==================================================================================================
32/// Holds static objects used for standard debug logging and provides an interface to
33/// create such objects. If the compiler-symbol #ALOX_DBG_LOG is set to \c 0, this class will be empty.
34//==================================================================================================
35class Log
36{
37 public:
38 #if ALOX_DBG_LOG
39 /// The debug logger created by AddDebugLogger.
41
42 /// An (additional) IDE specific logger, that might be created by AddDebugLogger.
44
45 /// Returns the default singleton of class \b %Lox used for debug logging.
46 /// @return The debug-logging Lox of \alox
47 static Lox* Get() { return DEBUG_LOX; }
48
49 /// This method creates an adequate/default debug logger.
50 /// It is used by macro \ref Log_AddDebugLogger also automatically invoked
51 /// when debug logging is used without the explicit creation and registration of
52 /// any other logger.
53 ///
54 /// Of course, alternatively to using this method (resp. the macro), a suitable (set of)
55 /// debug logger(s) can be created manually. Also, before or after using this method
56 /// additional debug loggers may be created.
57 ///
58 /// In the current version of \alox (future changes are likely), this method does:
59 /// - use
60 /// \ref alib::lox::Lox::CreateConsoleLogger "Lox::CreateConsoleLogger"
61 /// to create the best compatible console logger for the
62 /// running platform
63 /// - this logger will be added to the debug Lox object with specifying
64 /// \c Verbosity::Error for internal domains.
65 /// - If under windows, a Visual Studio debug session is running, adds a
66 /// \ref alib::lox::loggers::VStudioLogger "VStudioLogger"
67 /// in addition to the standard console logger. This can be suppressed using
68 /// configuration variable \ref alxcvALOX_NO_IDE_LOGGER.
69 ///
70 /// The name of the \e Logger created is \c "DEBUG_LOGGER". It will be registered with
71 /// the standard \b %Lox used for debug-logging, by setting \e Verbosities
72 /// - Verbosity::Verbose for the root domain <c> '/'</c> and
73 /// - Verbosity::Warning for internal domains.
74 ///
75 /// An optionally created second, IDE-specific \e Logger will be named \c "IDE_LOGGER"
76 /// and will be registered with the standard \b %Lox used for debug-logging with the same
77 /// \e Verbosities as \c "DEBUG_LOGGER" is.
78 ///
79 /// Finally, this method also invokes #SetALibAssertionPlugin.
80 ///
81 /// @param lox The lox to add the debug logger(s) to.
82 ALIB_DLL static void AddDebugLogger( Lox* lox );
83
84 /// Removes the \e Logger(s) and which was (were) created by \ref AddDebugLogger.
85 /// This method also invokes #SetALibAssertionPlugin, passing \c nullptr to unregister
86 /// the plug-in.
87 /// @param lox The lox to remove the debug logger(s) from.
88 ALIB_DLL static void RemoveDebugLogger( Lox* lox );
89
90 #if ALIB_DEBUG
91 /// Sets the global pointer \alib{assert::PLUGIN} to function
92 /// \alib{lox;ALoxAssertionPlugin} which then redirects the output of
93 /// \ref #alib::assert::Raise "ALib assertions" to the given \alib{lox;Lox}.
94 ///
95 /// \note
96 /// This method is effective only with debug-builds. Usually it is invoked indirectly by
97 /// using the method #AddDebugLogger.
98 /// Applications that do not use that method (e.g., because they are using release
99 /// logging exclusively) should invoke this method on bootstrap providing their
100 /// (release) lox.
101 /// In this case, the \e Verbosity of the internal domain used by function
102 /// \alib{lox;ALoxAssertionPlugin} has to be set for the logger(s) in the given
103 /// \p{lox} in question.
104 ///
105 /// @param lox The lox that the \alib{lox;ALoxAssertionPlugin} will be using.
106 /// If \c nullptr is given, the plug-in will be removed.
107 ALIB_DLL static void SetALibAssertionPlugin( Lox* lox );
108 #else
109 static void SetALibAssertionPlugin( Lox* ) {}
110 #endif
111
112 #endif // ALOX_DBG_LOG
113}; // class Log
114
115} // namespace alib[::lox]
116
117/// Type alias in namespace \b alib.
119
120} // namespace [alib]
121
122
static ALIB_DLL textlogger::TextLogger * DebugLogger
The debug logger created by AddDebugLogger.
Definition log.inl:40
static ALIB_DLL void RemoveDebugLogger(Lox *lox)
Definition alox.cpp:275
static ALIB_DLL void AddDebugLogger(Lox *lox)
Definition alox.cpp:207
static Lox * Get()
Definition log.inl:47
static ALIB_DLL void SetALibAssertionPlugin(Lox *lox)
Definition alox.cpp:336
static ALIB_DLL textlogger::TextLogger * IDELogger
An (additional) IDE specific logger, that might be created by AddDebugLogger.
Definition log.inl:43
This class acts as a container for Loggers and provides a convenient interface to logging.
Definition lox.inl:15
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_EXPORT
Definition alib.inl:488
This namespaces defines class TextLogger and its helpers.
Definition loxpimpl.inl:13
std::string_view const ALOX_ASSERTION_PLUGIN_DOMAIN_PREFIX
Definition alox.cpp:330
ALIB_DLL Lox * DEBUG_LOX
lox::Log Log
Type alias in namespace alib.
Definition log.inl:118