paysages3d/src/system/Logs.cpp

60 lines
845 B
C++
Raw Normal View History

#include "Logs.h"
2015-09-14 17:25:54 +00:00
#include "Time.h"
static std::ostream NULL_STREAM(0);
static bool enabled = true;
std::ostream &Logs::debug()
{
#ifdef NDEBUG
return NULL_STREAM;
#else
if (enabled)
{
std::cout << "DEBUG - ";
return std::cout;
}
else
{
return NULL_STREAM;
}
#endif
}
std::ostream &Logs::warning()
{
if (enabled)
{
std::cerr << "WARN - ";
return std::cerr;
}
else
{
return NULL_STREAM;
}
}
std::ostream &Logs::error()
{
if (enabled)
{
std::cerr << "ERROR - ";
return std::cerr;
}
else
{
return NULL_STREAM;
}
}
2015-09-14 17:25:54 +00:00
void Logs::debugTimestamp(const std::string &message)
{
debug() << Time::getRelativeTimeMs() << " - " << message << std::endl;
}
void Logs::disable()
{
enabled = false;
}