[ox/std] Add oxTracef
This commit is contained in:
16
deps/ox/src/ox/std/tracehook.cpp
vendored
16
deps/ox/src/ox/std/tracehook.cpp
vendored
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user