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