From 0670f19eba22721adb2c48aab8c5bddb2b59d352 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 4 Oct 2018 12:44:54 +0200 Subject: [PATCH] debug: Allow setting trace float precision globally --- src/debug.cpp | 4 ++-- src/debug.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 19d5a8c..94cba13 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -4,7 +4,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) { IOSave s(os); - os << std::setprecision(3); + os << std::setprecision(DbgTracer::precision); os << p.obj.size << " " << p.obj.channels() << "ch ";// << static_cast(p.obj.data); os << " = [ "; constexpr size_t num = 10; @@ -17,7 +17,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) { IOSave s(os); - os << std::setprecision(3); + os << std::setprecision(DbgTracer::precision); os << " " << p.obj.size() << " " << p.obj.channels() << "ch "; // << p.obj.get_p_data(); constexpr int num = 10; for (uint s = 0; s < p.obj.n_scales; ++s) { diff --git a/src/debug.h b/src/debug.h index 73ff1e9..6ad1d18 100644 --- a/src/debug.h +++ b/src/debug.h @@ -41,6 +41,7 @@ class DbgTracer { public: bool debug = false; + static constexpr int precision = 2; std::string indent() { return std::string(indentLvl * 4, ' '); } @@ -78,6 +79,8 @@ class DbgTracer { #ifdef CUFFT CudaSafeCall(cudaStreamSynchronize(cudaStreamPerThread)); #endif + IOSave s(std::cerr); + std::cerr << std::setprecision(precision); std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl; } } -- 2.39.2