ALib C++ Framework
by
Library Version:
2511 R0
Documentation generated by
Loading...
Searching...
No Matches
A-Worx
ALib
src
alib
alox
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 #"mainpage_license".
7
//==================================================================================================
8
ALIB_EXPORT
namespace
alib
{
namespace
lox
{
9
10
// forward declarations
11
class
Lox
;
12
#if !ALIB_C20_MODULES
13
namespace
detail
{
class
Logger
; }
14
namespace
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
//==================================================================================================
35
class
Log
36
{
37
public
:
38
#if ALOX_DBG_LOG
39
/// The debug logger created by AddDebugLogger.
40
ALIB_DLL
static
textlogger::TextLogger
*
DEBUG_LOGGER
;
41
42
/// An (additional) IDE specific logger, that might be created by AddDebugLogger.
43
ALIB_DLL
static
textlogger::TextLogger
*
IDE_LOGGER
;
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 #"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
/// #"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
/// #"alib::lox::loggers::VStudioLogger;VStudioLogger"
67
/// in addition to the standard console logger. This can be suppressed using
68
/// configuration variable #"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 #"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 #"assert::PLUGIN" to function
92
/// #"ALoxAssertionPlugin" which then redirects the output of
93
/// #"alib::assert::Raise;ALib assertions" to the given #"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
/// #"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 #"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.
118
using
Log
=
lox::Log
;
119
120
}
// namespace [alib]
ALIB_DLL
#define ALIB_DLL
Definition
alib.inl:573
ALIB_EXPORT
#define ALIB_EXPORT
Definition
alib.inl:562
alib::lox::Log
Definition
log.inl:36
alib::lox::Log::IDE_LOGGER
static textlogger::TextLogger * IDE_LOGGER
An (additional) IDE specific logger, that might be created by AddDebugLogger.
Definition
log.inl:43
alib::lox::Log::RemoveDebugLogger
static void RemoveDebugLogger(Lox *lox)
Definition
alox.cpp:256
alib::lox::Log::AddDebugLogger
static void AddDebugLogger(Lox *lox)
Definition
alox.cpp:194
alib::lox::Log::DEBUG_LOGGER
static textlogger::TextLogger * DEBUG_LOGGER
The debug logger created by AddDebugLogger.
Definition
log.inl:40
alib::lox::Log::Get
static Lox * Get()
Definition
log.inl:47
alib::lox::Log::SetALibAssertionPlugin
static void SetALibAssertionPlugin(Lox *lox)
Definition
alox.cpp:314
alib::lox::Lox
This class acts as a container for Loggers and provides a convenient interface to logging.
Definition
lox.inl:14
alib::lox::detail::Logger
Definition
logger.inl:36
alib::lox::textlogger::TextLogger
Definition
textlogger.inl:136
alib::lox::detail
Definition
domain.cpp:40
alib::lox::textlogger
This namespaces defines class TextLogger and its helpers.
Definition
loxpimpl.inl:13
alib::lox
Definition
alox.cpp:59
alib::lox::DEBUG_LOX
Lox * DEBUG_LOX
alib::lox::ALOX_ASSERTION_PLUGIN_DOMAIN_PREFIX
std::string_view const ALOX_ASSERTION_PLUGIN_DOMAIN_PREFIX
Definition
alox.cpp:308
alib
Definition
ALib.Boxing.StdFunctors.H:18
alib::Log
lox::Log Log
Type alias in namespace alib.
Definition
log.inl:118