[ox/std] Add oxTracef

This commit is contained in:
2021-03-10 20:14:31 -06:00
parent ef6673067b
commit 55a4f2451e
9 changed files with 283 additions and 99 deletions

View File

@@ -6,6 +6,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#if defined(OX_USE_STDLIB)
#include <iomanip>
#include <iostream>
static const auto OxPrintTrace = std::getenv("OXTRACE") != nullptr;
#else
constexpr auto OxPrintTrace = false;
#endif
extern "C" {
void oxTraceInitHook() {
@@ -13,6 +22,13 @@ void oxTraceInitHook() {
void oxTraceHook([[maybe_unused]] const char *file, [[maybe_unused]] int line,
[[maybe_unused]] const char *ch, [[maybe_unused]] const char *msg) {
#if defined(OX_USE_STDLIB)
if (OxPrintTrace) {
std::cout << std::setw(53) << std::left << ch << "| ";
std::cout << std::setw(65) << std::left << msg << '|';
std::cout << " " << file << ':' << line << "\n";
}
#endif
}
}