From 9d4bad02e6eb15ec5cf62681923543776d66e9f1 Mon Sep 17 00:00:00 2001 From: Jason Maskell Date: Tue, 31 May 2016 13:54:29 +0200 Subject: Renamed Logger.h to GFSDK_Logger.h since it's a shared header. Removed the narrow char methods. Removed the floating log functions. Changed the ILogger::log() method to use varargs and printf() formatting. --- src/InternalLogger.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/InternalLogger.cpp') diff --git a/src/InternalLogger.cpp b/src/InternalLogger.cpp index e8e8898..de1f750 100644 --- a/src/InternalLogger.cpp +++ b/src/InternalLogger.cpp @@ -27,26 +27,28 @@ void InternalLogger::setLoggingLevel(nv::LogSeverity newLevel) LoggingLevel = newLevel; } -void InternalLogger::log(const char* text, nv::LogSeverity severity, const char* filename, int linenumber) +void InternalLogger::log(nv::LogSeverity severity, const wchar_t* filename, int linenumber, const wchar_t* format, ...) { if (getLoggingLevel() > severity) return; - std::ostringstream out; + wchar_t buffer[1024]; - out << filename << "(" << linenumber << "): " << "[" << nv::LogSeverityStrings[(int)severity] << "] " << text << std::endl; - - OutputDebugStringA(out.str().c_str()); -} - -void InternalLogger::log(const wchar_t* text, nv::LogSeverity severity, const wchar_t* filename, int linenumber) -{ - if (getLoggingLevel() > severity) - return; + 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); 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()); } -- cgit v1.2.3