[ox/trace] Add environment variable to enable logging

This commit is contained in:
Gary Talent 2018-07-30 22:12:20 -05:00
parent 95b72d19fb
commit 2e19e297d9

View File

@ -17,6 +17,8 @@
namespace ox::trace {
static const auto OxPrintTrace = std::getenv("OXTRACE") != nullptr;
OutStream::OutStream(const char *file, int line, const char *ch, const char *msg) {
m_msg.file = file;
m_msg.line = line;
@ -41,9 +43,11 @@ StdOutStream::StdOutStream(const char *file, int line, const char *ch, const cha
StdOutStream::~StdOutStream() {
#if defined(OX_USE_STDLIB)
if (OxPrintTrace) {
std::cout << std::setw(53) << std::left << m_msg.ch.c_str() << '|';
std::cout << std::setw(65) << std::left << m_msg.msg.c_str() << '|';
std::cout << " " << m_msg.file.c_str() << ':' << m_msg.line << "\n";
}
#endif
}