[ox/trace] Add environment variable to enable logging
This commit is contained in:
parent
95b72d19fb
commit
2e19e297d9
10
deps/ox/src/ox/trace/trace.cpp
vendored
10
deps/ox/src/ox/trace/trace.cpp
vendored
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
namespace ox::trace {
|
namespace ox::trace {
|
||||||
|
|
||||||
|
static const auto OxPrintTrace = std::getenv("OXTRACE") != nullptr;
|
||||||
|
|
||||||
OutStream::OutStream(const char *file, int line, const char *ch, const char *msg) {
|
OutStream::OutStream(const char *file, int line, const char *ch, const char *msg) {
|
||||||
m_msg.file = file;
|
m_msg.file = file;
|
||||||
m_msg.line = line;
|
m_msg.line = line;
|
||||||
@ -41,9 +43,11 @@ StdOutStream::StdOutStream(const char *file, int line, const char *ch, const cha
|
|||||||
|
|
||||||
StdOutStream::~StdOutStream() {
|
StdOutStream::~StdOutStream() {
|
||||||
#if defined(OX_USE_STDLIB)
|
#if defined(OX_USE_STDLIB)
|
||||||
std::cout << std::setw(53) << std::left << m_msg.ch.c_str() << '|';
|
if (OxPrintTrace) {
|
||||||
std::cout << std::setw(65) << std::left << m_msg.msg.c_str() << '|';
|
std::cout << std::setw(53) << std::left << m_msg.ch.c_str() << '|';
|
||||||
std::cout << " " << m_msg.file.c_str() << ':' << m_msg.line << "\n";
|
std::cout << std::setw(65) << std::left << m_msg.msg.c_str() << '|';
|
||||||
|
std::cout << " " << m_msg.file.c_str() << ':' << m_msg.line << "\n";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user