diff options
Diffstat (limited to 'common/LoggerImpl.cpp')
| -rw-r--r-- | common/LoggerImpl.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/common/LoggerImpl.cpp b/common/LoggerImpl.cpp index 9a2921d..9fa81bd 100644 --- a/common/LoggerImpl.cpp +++ b/common/LoggerImpl.cpp @@ -3,10 +3,8 @@ #include <sstream> #include <windows.h> -LoggerWWSamples* g_Logger = nullptr; - LoggerWWSamples::LoggerWWSamples(): -LoggingLevel(nv::LogSeverity::kInfo) + LoggingLevel(nv::LogSeverity::kInfo) { } @@ -27,20 +25,28 @@ void LoggerWWSamples::setLoggingLevel(nv::LogSeverity newLevel) LoggingLevel = newLevel; } -void LoggerWWSamples::log(const char* text, nv::LogSeverity severity, const char* filename, int linenumber) +void LoggerWWSamples::log(nv::LogSeverity severity, const wchar_t* filename, int linenumber, const wchar_t* format, ...) { - std::ostringstream out; - - out << filename << "(" << linenumber << "): " << "[" << nv::LogSeverityStrings[(int) severity] << "] " << text << std::endl; + if (getLoggingLevel() > severity) + return; + + wchar_t buffer[1024]; + + va_list args; + va_start(args, format); +#if NV_GCC_FAMILY +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif + _vsnwprintf_s(buffer, sizeof(buffer), format, args); +#if NV_GCC_FAMILY +#pragma GCC diagnostic pop +#endif + va_end(args); - OutputDebugStringA(out.str().c_str()); -} - -void LoggerWWSamples::log(const wchar_t* text, nv::LogSeverity severity, const wchar_t* filename, int linenumber) -{ std::wstringstream out; - out << filename << "(" << linenumber << "): " << "[" << nv::LogSeverityStrings[(int)severity] << "] " << text << std::endl; + out << filename << "(" << linenumber << "): " << "[" << nv::LogSeverityStrings[(int)severity] << "] " << buffer << std::endl; OutputDebugStringW(out.str().c_str()); } |