10 if (!
ref_count.compare_exchange_strong(expected,
true))
12 throw std::logic_error(
"Only one instance of StdCoutLogger shall be created");
23 using namespace std::chrono;
25 constexpr
const char* whitespaces =
" ";
26 constexpr
const size_t ws_count = 25;
28 double since_epoch = duration<double>(timestamp).
count();
29 printf(
"[%.3f]: %s%s %s -> %s", since_epoch, node.
name().c_str(),
30 &whitespaces[std::min(ws_count, node.
name().size())],
toStr(prev_status,
true),
32 std::cout << std::endl;
37 std::cout << std::flush;
const std::string & name() const
static std::atomic< bool > ref_count
StdCoutLogger(TreeNode *root_node)
const char * toStr(const BT::NodeStatus &status, bool colored=false)
toStr converts NodeStatus to string. Optionally colored.
static volatile int count
virtual void flush() override
std::chrono::high_resolution_clock::duration Duration
virtual void callback(Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override