utx::cb_track is the callback tracker, to track how one api is calling back another.
It will display information with color highlighting.
Utxcpp track and utxcpp core doesn't depend on each other.
class cb_track {
class cb_track { private: class Printer;
cb_track() = delete; cb_track(const cb_track &) = delete; cb_track & operator=(const cb_track &) = delete;
Create an utx::cb_track object and reset the underlying track_target and optional_string value.
cb_track(const std::string & target) noexcept; // (1) cb_track(const std::string & target, const std::string & optional) noexcept; // (2) cb_track(const std::string & target, const T & optional) noexcept; // (3)
![]() |
Note |
---|---|
|
Reset the underlying track_target and optional_string value.
void reset(const std::string & target) noexcept; // (1) void reset(const std::string & target, const std::string & optional) noexcept; // (2) void reset(const std::string & target, const T & optional) noexcept; // (3)
![]() |
Note |
---|---|
|
Printer & operator()(); // (1) Printer & operator()(const std::string & target); // (2) Printer & operator()(const std::string & target, const std::string & optional); // (3) Printer & operator()(const std::string & target, const T & optional); // (4)
![]() |
Note |
---|---|
|
#include <utxcpp/track.hpp> class Hello { public: Hello() {utx::cb_track{"Hello"}() << '\n';} ~Hello() {utx::cb_track{"~Hello", '\n'}();} void fn() {utx::cb_track{"fn", "\n"}();} }; class World { private: utx::cb_track track{"World", "\n"}; public: World() {track();} ~World() {track.reset("~World", '\n'); track();} void fn() {track.reset("fn", "\n"); track();} }; class Fizz { private: utx::cb_track track{"class-Fizz"}; public: Fizz() { track() << "Constructor.\n"; } ~Fizz() { track.reset("~Fizz"); track() << "Destructor.\n"; } void fn() { track.reset("Fizz::fn()", "Fizz::fn() is a useful method.\n"); track(); } void func() { track("Fizz::func()", "another method.\n"); track.reset("Fizz::func"); track() << "--------\n"; } }; int main() { std::clog << "------------------------------------------------------------------------\n"; {Hello{}.fn();} std::clog << "------------------------------------------------------------------------\n"; {World{}.fn();} std::clog << "------------------------------------------------------------------------\n"; {Fizz().fn();} std::clog << "------------------------------------------------------------------------\n"; {Fizz().func();} }
Output Result:
------------------------------------------------------------------------ [utx::cb_track *** Hello] [utx::cb_track *** fn] [utx::cb_track *** ~Hello] ------------------------------------------------------------------------ [utx::cb_track *** World] [utx::cb_track *** fn] [utx::cb_track *** ~World] ------------------------------------------------------------------------ [utx::cb_track *** class-Fizz] Constructor. [utx::cb_track *** Fizz::fn()] Fizz::fn() is a useful method. [utx::cb_track *** ~Fizz] Destructor. ------------------------------------------------------------------------ [utx::cb_track *** class-Fizz] Constructor. [utx::cb_track *** Fizz::func()] another method. [utx::cb_track *** Fizz::func] -------- [utx::cb_track *** ~Fizz] Destructor.
Last revised: June 13, 2022 at 03:08:21 GMT |