24#ifndef MYSQL_DEBUGGING_OBJECT_LIFETIME_TRACKER_H
25#define MYSQL_DEBUGGING_OBJECT_LIFETIME_TRACKER_H
48template <
int channel = 0>
50 static std::atomic<Tracker_id> tracker_id_counter = 0;
51 Tracker_id ret = tracker_id_counter.fetch_add(1);
74template <
class Self_tp =
void>
77 static constexpr bool known_type = !std::same_as<Self_tp, void>;
80 static constexpr const char *
m_reset =
"\033[30m";
81 static constexpr const char *
m_red =
"\033[31m";
82 static constexpr const char *
m_green =
"\033[32m";
83 static constexpr const char *
m_yellow =
"\033[33m";
84 static constexpr const char *
m_blue =
"\033[34m";
85 static constexpr const char *
m_magenta =
"\033[35m";
86 static constexpr const char *
m_cyan =
"\033[36m";
87 static constexpr const char *
grey =
"\033[37m";
164 void log_for(
const auto &
id,
const auto &...args)
const {
165 do_log(
id,
": ", args...,
"\n");
174 return type_name<Self_tp>();
213 (std::cout << ... << args);
Debug facility to log constructor/assignment/destructor usage for a class.
Definition: object_lifetime_tracker.h:75
Object_lifetime_tracker(Object_lifetime_tracker &&other) noexcept
Copy-construct using the message "Move-construct from ID".
Definition: object_lifetime_tracker.h:127
void log_move(Tracker_id id) const
Write a message on behalf of a moved-from object.
Definition: object_lifetime_tracker.h:207
Object_lifetime_tracker() noexcept
Default constructor.
Definition: object_lifetime_tracker.h:91
Object_lifetime_tracker & operator=(Object_lifetime_tracker &&other) noexcept
Move-construct using the message "Move-assign from ID".
Definition: object_lifetime_tracker.h:146
void log_assign(std::string_view flavor, Tracker_id source) const
Write a message during object assignment.
Definition: object_lifetime_tracker.h:202
static constexpr const char * m_magenta
Definition: object_lifetime_tracker.h:85
Tracker_id tracker_id() const
Return the ID for this object.
Definition: object_lifetime_tracker.h:169
void log_construct_from(std::string_view flavor, Tracker_id source) const
Write a message during object construction, including a " from SOURCE" text.
Definition: object_lifetime_tracker.h:192
static constexpr const char * m_cyan
Definition: object_lifetime_tracker.h:86
Object_lifetime_tracker(std::string_view flavor, Tracker_id source) noexcept
Construct using the message "FLAVOR-construct from SOURCE".
Definition: object_lifetime_tracker.h:106
std::string_view type_name() const
Return the type of this object (not demangled).
Definition: object_lifetime_tracker.h:172
Object_lifetime_tracker & operator=(const Object_lifetime_tracker &other) noexcept
Copy-construct using the message "Copy-assign from ID".
Definition: object_lifetime_tracker.h:137
void log(const auto &...args) const
Write a message to the log.
Definition: object_lifetime_tracker.h:158
~Object_lifetime_tracker() noexcept
Destruct using the message "Destruct".
Definition: object_lifetime_tracker.h:153
static constexpr const char * m_blue
Definition: object_lifetime_tracker.h:84
Object_lifetime_tracker(std::string_view flavor) noexcept
Construct using the message "FLAVOR-construct".
Definition: object_lifetime_tracker.h:98
Tracker_id m_id
Definition: object_lifetime_tracker.h:219
static constexpr bool known_type
Definition: object_lifetime_tracker.h:77
static constexpr const char * m_red
Definition: object_lifetime_tracker.h:81
void log_construct(std::string_view flavor) const
Write a message during object construction.
Definition: object_lifetime_tracker.h:182
void do_log(const auto &...args) const
Low level to log any message.
Definition: object_lifetime_tracker.h:212
static constexpr const char * m_green
Definition: object_lifetime_tracker.h:82
static constexpr const char * m_yellow
Definition: object_lifetime_tracker.h:83
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.
Definition: object_lifetime_tracker.h:164
static constexpr const char * grey
Definition: object_lifetime_tracker.h:87
static constexpr const char * m_reset
Definition: object_lifetime_tracker.h:80
Object_lifetime_tracker(const Object_lifetime_tracker &other) noexcept
Copy-construct using the message "Copy-construct from ID".
Definition: object_lifetime_tracker.h:117
mrs::interface::RestHandler::HttpResult::Type Type
Definition: handler_content_file.cc:42
Definition: object_lifetime_tracker.h:37
std::string_view type_name()
Return the name of the given type (not demangled).
Definition: object_lifetime_tracker.h:57
int Tracker_id
Integral type used to uniquely identify objects.
Definition: object_lifetime_tracker.h:40
Tracker_id tracker_get_object_id()
The value to use for m_id next time we construct an Allocator.
Definition: object_lifetime_tracker.h:49
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
case opt name
Definition: sslopt-case.h:29