-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdprintf.cpp
54 lines (44 loc) · 1.03 KB
/
dprintf.cpp
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
53
54
//////////////////////////////////////////////////////////////////////////////
// dprintf.h
// See header file for description.
//
#include <stdarg.h>
#include <stdio.h>
#include <openvr_driver.h>
#if defined(_WIN32)
#include <windows.h>
// disable vc fopen warning
#pragma warning(disable : 4996)
#define vsprintf vsprintf_s
#endif
void dprintf(const char *fmt, ...)
{
va_list args;
char buffer[2048];
va_start(args, fmt);
vsprintf(buffer, fmt, args);
va_end(args);
#if !defined(NDEBUG)
static FILE *factory_log;
if (factory_log == 0)
{
factory_log = fopen("c:\\temp\\soft_knuckles_log.txt", "wt");
if (!factory_log)
{
factory_log = fopen("c:\\temp\\soft_knuckles_log1.txt", "wt");
}
}
if (factory_log)
{
fprintf(factory_log, "%s", buffer);
fflush(factory_log);
}
#ifdef WIN32
OutputDebugStringA(buffer);
#endif
#endif
if (vr::VRDriverContext() && vr::VRDriverLog())
{
vr::VRDriverLog()->Log(buffer);
}
}