diff --git a/framework/debug.cpp b/framework/debug.cpp index 5f551e9..9ec4717 100644 --- a/framework/debug.cpp +++ b/framework/debug.cpp @@ -1,5 +1,7 @@ #include "include/public/toon_boom/ext/util.hpp" +namespace util::debug { std::ostream devnull(new NullBuffer()); std::ostream& out = TB_EXT_FRAMEWORK_DEBUG ? std::cout : devnull; +} diff --git a/framework/include/public/toon_boom/ext/layout.hpp b/framework/include/public/toon_boom/ext/layout.hpp index e6bcf55..95226b0 100644 --- a/framework/include/public/toon_boom/ext/layout.hpp +++ b/framework/include/public/toon_boom/ext/layout.hpp @@ -1,6 +1,7 @@ #pragma once #include "../PLUG_Services.hpp" #include "../toon_boom_layout.hpp" +#include "./util.hpp" #include "QtXml/qdom.h" #include #include @@ -9,6 +10,7 @@ #include #include +using namespace util; template concept isQWidget = std::is_base_of::value; @@ -100,7 +102,7 @@ protected: QObject::connect( parent, &QObject::destroyed, m_widget.data(), [this]() { - std::cout << "[parent destroyed] Unparenting widget to prevent " + debug::out << "[parent destroyed] Unparenting widget to prevent " "cross-DLL heap deletion" << std::endl; if (m_widget) { @@ -123,10 +125,10 @@ protected: if (am) { QList ids; am->loadToolbars(element, ids); - std::cout << "Registered toolbar with AC_Manager. IDs loaded: " + debug::out << "Registered toolbar with AC_Manager. IDs loaded: " << ids.size() << std::endl; for (const auto &id : ids) { - std::cout << " - " << id.toStdString() << std::endl; + debug::out << " - " << id.toStdString() << std::endl; } } else { std::cerr << "Could not get AC_Manager!" << std::endl; diff --git a/framework/include/public/toon_boom/ext/util.hpp b/framework/include/public/toon_boom/ext/util.hpp index 3f9d826..0bb2f09 100644 --- a/framework/include/public/toon_boom/ext/util.hpp +++ b/framework/include/public/toon_boom/ext/util.hpp @@ -7,6 +7,8 @@ #if !defined(TB_EXT_FRAMEWORK_DEBUG) #define TB_EXT_FRAMEWORK_DEBUG 0 #endif + +namespace util::debug { struct NullBuffer : std::streambuf { int overflow(int c) { return c; } }; @@ -16,3 +18,4 @@ std::string addrToHex(void *addr); std::string constAddrToHex(const void *addr); extern std::ostream &out; +} // namespace util::debug \ No newline at end of file diff --git a/framework/util.cpp b/framework/util.cpp index 06980f9..6022255 100644 --- a/framework/util.cpp +++ b/framework/util.cpp @@ -1,9 +1,11 @@ #include "include/public/toon_boom/ext/util.hpp" +namespace util::debug { std::string addrToHex(void* addr) { return std::format("0x{:010X}", reinterpret_cast(addr)); } std::string constAddrToHex(const void* addr) { return std::format("0x{:010X}", reinterpret_cast(addr)); -} \ No newline at end of file +} +} // namespace util::debug \ No newline at end of file