summaryrefslogtreecommitdiff
path: root/common/LoggerImpl.cpp
blob: 9fa81bd09f70d7950b79a82e27db32004716ae71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "LoggerImpl.h"
#include <iostream>
#include <sstream>
#include <windows.h>

LoggerWWSamples::LoggerWWSamples():
	LoggingLevel(nv::LogSeverity::kInfo)
{

}

LoggerWWSamples::LoggerWWSamples(nv::LogSeverity loggingLevel) :
	LoggingLevel(loggingLevel)
{

}

nv::LogSeverity LoggerWWSamples::getLoggingLevel()
{
	return LoggingLevel;
}

void LoggerWWSamples::setLoggingLevel(nv::LogSeverity newLevel)
{
	LoggingLevel = newLevel;
}

void LoggerWWSamples::log(nv::LogSeverity severity, const wchar_t* filename, int linenumber, const wchar_t* format, ...)
{
	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);

	std::wstringstream out;

	out << filename << "(" << linenumber << "): " << "[" << nv::LogSeverityStrings[(int)severity] << "] " << buffer << std::endl;

	OutputDebugStringW(out.str().c_str());
}