diff options
| author | Jason Maskell <[email protected]> | 2016-05-31 13:54:29 +0200 |
|---|---|---|
| committer | Jason Maskell <[email protected]> | 2016-05-31 13:54:29 +0200 |
| commit | 9d4bad02e6eb15ec5cf62681923543776d66e9f1 (patch) | |
| tree | 1f64f36d04a518a1369ce9e34ba30b0debea1b9f /src/InternalLogger.cpp | |
| parent | Added support for RFC 104, the logging interface: https://docs.google.com/doc... (diff) | |
| download | waveworks_archive-9d4bad02e6eb15ec5cf62681923543776d66e9f1.tar.xz waveworks_archive-9d4bad02e6eb15ec5cf62681923543776d66e9f1.zip | |
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.
Diffstat (limited to 'src/InternalLogger.cpp')
| -rw-r--r-- | src/InternalLogger.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
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()); } |