From 446ce137c6823ba9eff273bdafdaf266287c7c98 Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Tue, 21 Feb 2017 12:07:59 -0800 Subject: first commit --- NvBlast/tools/common/Log.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 NvBlast/tools/common/Log.cpp (limited to 'NvBlast/tools/common/Log.cpp') diff --git a/NvBlast/tools/common/Log.cpp b/NvBlast/tools/common/Log.cpp new file mode 100644 index 0000000..4371a7d --- /dev/null +++ b/NvBlast/tools/common/Log.cpp @@ -0,0 +1,59 @@ +#include "Log.h" + +#include "PsString.h" + +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +namespace Nv +{ +namespace Blast +{ + +void fLogf(const char* format, ...) +{ + char buf[4096], *p = buf; + va_list args; + int n; + + va_start(args, format); + //n = _vsnprintf(p, sizeof buf - 3, format, args); + n = vsprintf_s(p, sizeof(buf)-3, format, args); + va_end(args); + + p += (n < 0) ? sizeof buf - 3 : n; + + while (p > buf && isspace((unsigned char)p[-1])) + { + *--p = '\0'; + } + + *p++ = '\r'; + *p++ = '\n'; + *p = '\0'; + + fLog(buf, Log::TYPE_INFO); +} + + +////////////////////////////////////////////////////////////////////////////// + +void Log::flushDeferredMessages() +{ + if (mDeferredMessages.size() == 0) return; + + std::cout << std::endl; + for (std::vector::iterator it = mDeferredMessages.begin(); it != mDeferredMessages.end(); ++it) + { + log(*it, mMinVerbosity); + } + mDeferredMessages.clear(); +} + + + +} // namespace Blast +} // namespace Nv -- cgit v1.2.3