![]() |
MySQL 9.6.0
Source Code Documentation
|
Debug facility to log constructor/assignment/destructor usage for a class. More...
#include <object_lifetime_tracker.h>
Public Member Functions | |
| Object_lifetime_tracker () noexcept | |
| Default constructor. More... | |
| Object_lifetime_tracker (std::string_view flavor) noexcept | |
| Construct using the message "FLAVOR-construct". More... | |
| Object_lifetime_tracker (std::string_view flavor, Tracker_id source) noexcept | |
| Construct using the message "FLAVOR-construct from SOURCE". More... | |
| Object_lifetime_tracker (const Object_lifetime_tracker &other) noexcept | |
| Copy-construct using the message "Copy-construct from ID". More... | |
| Object_lifetime_tracker (Object_lifetime_tracker &&other) noexcept | |
| Copy-construct using the message "Move-construct from ID". More... | |
| Object_lifetime_tracker & | operator= (const Object_lifetime_tracker &other) noexcept |
| Copy-construct using the message "Copy-assign from ID". More... | |
| Object_lifetime_tracker & | operator= (Object_lifetime_tracker &&other) noexcept |
| Move-construct using the message "Move-assign from ID". More... | |
| ~Object_lifetime_tracker () noexcept | |
| Destruct using the message "Destruct". More... | |
| void | log (const auto &...args) const |
| Write a message to the log. More... | |
| void | log_for (const auto &id, const auto &...args) const |
| Write a message to the log, on behalf of another object having the given ID. More... | |
| Tracker_id | tracker_id () const |
| Return the ID for this object. More... | |
| std::string_view | type_name () const |
| Return the type of this object (not demangled). More... | |
Private Member Functions | |
| void | log_construct (std::string_view flavor) const |
| Write a message during object construction. More... | |
| void | log_construct_from (std::string_view flavor, Tracker_id source) const |
| Write a message during object construction, including a " from SOURCE" text. More... | |
| void | log_assign (std::string_view flavor, Tracker_id source) const |
| Write a message during object assignment. More... | |
| void | log_move (Tracker_id id) const |
| Write a message on behalf of a moved-from object. More... | |
| void | do_log (const auto &...args) const |
| Low level to log any message. More... | |
Private Attributes | |
| Tracker_id | m_id |
Static Private Attributes | |
| static constexpr bool | known_type = !std::same_as<Self_tp, void> |
| static constexpr const char * | m_reset = "\033[30m" |
| static constexpr const char * | m_red = "\033[31m" |
| static constexpr const char * | m_green = "\033[32m" |
| static constexpr const char * | m_yellow = "\033[33m" |
| static constexpr const char * | m_blue = "\033[34m" |
| static constexpr const char * | m_magenta = "\033[35m" |
| static constexpr const char * | m_cyan = "\033[36m" |
| static constexpr const char * | grey = "\033[37m" |
Debug facility to log constructor/assignment/destructor usage for a class.
To make a class log such life cycle events, make it inherit from this class.
This is only for temporary use in debugging sessions and must never be used in released code (not even debug-only code). It is intended to aid in debugging memory related issues, such as objects used after destruction. It writes a line to stdout for every object life cycle event: to keep the output size manageable it is usually good to minimize the amount of problematic code before using this class.
| Self_tp | If given, log entries for constructor invocations will be annotated with the type name of this class. |
|
inlinenoexcept |
Default constructor.
|
inlineexplicitnoexcept |
Construct using the message "FLAVOR-construct".
This is usable in custom subclass constructors.
|
inlineexplicitnoexcept |
Construct using the message "FLAVOR-construct from SOURCE".
This is usable in custom subclass constructors.
|
inlinenoexcept |
Copy-construct using the message "Copy-construct from ID".
This will be called when the subclass is copy-constructed, unless the subclass copy constructor explicitly invokes another constructor in this class.
|
inlinenoexcept |
Copy-construct using the message "Move-construct from ID".
This will be called when the subclass is move-constructed, unless the subclass move constructor explicitly invokes another constructor in this class.
|
inlinenoexcept |
Destruct using the message "Destruct".
|
inlineprivate |
Low level to log any message.
|
inline |
Write a message to the log.
The parameters will be passed to a std::stringstream using operator<<.
|
inlineprivate |
Write a message during object assignment.
|
inlineprivate |
Write a message during object construction.
|
inlineprivate |
Write a message during object construction, including a " from SOURCE" text.
|
inline |
Write a message to the log, on behalf of another object having the given ID.
The parameters will be passed to a std::stringstream using operator<<.
|
inlineprivate |
Write a message on behalf of a moved-from object.
|
inlinenoexcept |
Copy-construct using the message "Copy-assign from ID".
This will be called when the subclass is copy-assigned to.
|
inlinenoexcept |
Move-construct using the message "Move-assign from ID".
This will be called when the subclass is move-assigned to.
|
inline |
Return the ID for this object.
|
inline |
Return the type of this object (not demangled).
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |