VulkanRaytracingCycles 0.0.0
Cycles Render Engine With VulkanRaytracingShaderModules. ( Experiment , in progress)
log.cpp File Reference
#include "pch_mm.h"
#include "working_mm.h"
#include "log.hpp"
#include "global.hpp"

Go to the source code of this file.

Macros

#define STR(r)   case VK_ ##r: return #r
 

Functions

void testit (const char *fmt,...)
 
void log_init (void)
 
void exitFatal ()
 
void log_out (const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
 
void log__thread (const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
 
std::wstring to_wchar (const char *text)
 
void log__bad (const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
 
void log__vkabad (const char *file, int line, enum LOG_LEVEL level, VkResult code, const char *fmt,...)
 
void log__once (const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
 
void log__vs (const char *file, int line, enum LOG_LEVEL level, const char *fmt,...)
 
const char * errorString (VkResult errorCode)
 

Variables

bool FilePrintOn
 

Macro Definition Documentation

◆ STR

#define STR (   r)    case VK_ ##r: return #r

Function Documentation

◆ errorString()

const char * errorString ( VkResult  errorCode)

Definition at line 300 of file log.cpp.

301{
302 switch (errorCode)
303 {
304#define STR(r) case VK_ ##r: return #r
305 STR(NOT_READY);
306 STR(TIMEOUT);
307 STR(EVENT_SET);
308 STR(EVENT_RESET);
309 STR(INCOMPLETE);
310 STR(ERROR_OUT_OF_HOST_MEMORY);
311 STR(ERROR_OUT_OF_DEVICE_MEMORY);
312 STR(ERROR_INITIALIZATION_FAILED);
313 STR(ERROR_DEVICE_LOST);
314 STR(ERROR_MEMORY_MAP_FAILED);
315 STR(ERROR_LAYER_NOT_PRESENT);
316 STR(ERROR_EXTENSION_NOT_PRESENT);
317 STR(ERROR_FEATURE_NOT_PRESENT);
318 STR(ERROR_INCOMPATIBLE_DRIVER);
319 STR(ERROR_TOO_MANY_OBJECTS);
320 STR(ERROR_FORMAT_NOT_SUPPORTED);
321 STR(ERROR_SURFACE_LOST_KHR);
322 STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
323 STR(SUBOPTIMAL_KHR);
324 STR(ERROR_OUT_OF_DATE_KHR);
325 STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
326 STR(ERROR_VALIDATION_FAILED_EXT);
327 STR(ERROR_INVALID_SHADER_NV);
328#undef STR
329 default:
330 return "UNKNOWN_ERROR_";
331 }
332}
#define STR(r)

◆ exitFatal()

void exitFatal ( )

Definition at line 65 of file log.cpp.

66{
67
68
69 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
70#ifdef AEOLUS
71 //des.~DeallocatorVk();
72 //des.Holocaust();
73 PyErr_SetString(PyExc_TypeError, "BAD");
74 PyErr_NoMemory();
75#else
76 exit(-1);
77#endif
78 //
79
80}

◆ log__bad()

void log__bad ( const char *  file,
int  line,
enum LOG_LEVEL  level,
const char *  fmt,
  ... 
)

Definition at line 213 of file log.cpp.

214{
215
216
217 char message[512] = { 0 };
218
219 va_list args;
220 va_start(args, fmt);
221 vsprintf_s(message, fmt, args);
222 va_end(args);
223
224 int on_button;
225#ifdef UNICODE
226 on_button = MessageBox(NULL, to_wchar((std::string(file) + ":" + std::to_string(line) + " \n " + message).c_str()).c_str(),
227#else
228 on_button = MessageBox(NULL, (std::string(file) + ":" + std::to_string(line) + " \n " + message).c_str(),
229#endif
230 TEXT("!Bad!"), MB_YESNO | MB_ICONQUESTION);
231
232 if (on_button == IDYES)
233 MessageBox(NULL, TEXT("Be Killed!"),
234 TEXT("exit."), MB_OK);
235 else MessageBox(NULL, TEXT("Be Killed!"),
236 TEXT("exit."), MB_OK);
237
238 exitFatal();
239
240
241}
void exitFatal()
Definition: log.cpp:65
std::wstring to_wchar(const char *text)
Definition: log.cpp:203

◆ log__once()

void log__once ( const char *  file,
int  line,
enum LOG_LEVEL  level,
const char *  fmt,
  ... 
)

Definition at line 263 of file log.cpp.

264{
265
266
267 printf("%s:%d %s ", file, line, log_label(level));
268
269 va_list args;
270 va_start(args, fmt);
271 vprintf(fmt, args);
272 va_end(args);
273
274 printf("\x1b[0m\n");
275
276}

◆ log__thread()

void log__thread ( const char *  file,
int  line,
enum LOG_LEVEL  level,
const char *  fmt,
  ... 
)

Definition at line 182 of file log.cpp.

183{
184
185
186 printf("%s:%d %s ", file, line, log_label(level));
187
188 va_list args;
189 va_start(args, fmt);
190 vprintf(fmt, args);
191 va_end(args);
192
193 printf("\x1b[0m\n");
194
195#ifdef AEOLUS
196}
197#endif
198}

◆ log__vkabad()

void log__vkabad ( const char *  file,
int  line,
enum LOG_LEVEL  level,
VkResult  code,
const char *  fmt,
  ... 
)

Definition at line 243 of file log.cpp.

244{
245
246
247 printf("%s:%d %s VkaCode::%s ", file, line, log_label(level), errorString(code));
248
249 va_list args;
250 va_start(args, fmt);
251 vprintf(fmt, args);
252 va_end(args);
253
254 printf("\x1b[0m\n");
255
256 exitFatal();
257 //PyErr_BadArgument();
258 //PyErr_SetString(PyExc_TypeError, "BAD");
259 //throw ;
260
261}
const char * errorString(VkResult errorCode)
Definition: log.cpp:300

◆ log__vs()

void log__vs ( const char *  file,
int  line,
enum LOG_LEVEL  level,
const char *  fmt,
  ... 
)

Definition at line 279 of file log.cpp.

280{
281
282
283 char message[512] = { 0 };
284 std::string mg = std::string(file) + "::" + std::to_string(line);
285
286
287 va_list args;
288 va_start(args, fmt);
289 vsprintf_s(message, fmt, args);
290 va_end(args);
291
292 mg += std::string(" ") + message;
293
294 OutputDebugString(mg.c_str());
295
296}

◆ log_init()

void log_init ( void  )

log_info("Version : %s", git_version);

Definition at line 43 of file log.cpp.

44{
45
46#ifdef _WIN32
47 // AllocConsole();
48 // AttachConsole(GetCurrentProcessId());
49 // freopen("CON", "w", stdout);
50 // freopen("CON", "w", stderr);
51
52 // enable ANSI codes in windows console (conhost.exe)
53 // http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements
54 DWORD mode;
55 HANDLE console = GetStdHandle(-11); // STD_OUTPUT_HANDLE
56 GetConsoleMode(console, &mode);
57 mode = mode | 4; // ENABLE_VIRTUAL_TERMINAL_PROCESSING
58 SetConsoleMode(console, mode);
59#endif
62}
void sys_time_init(void)
Definition: global.cpp:63

◆ log_out()

void log_out ( const char *  file,
int  line,
enum LOG_LEVEL  level,
const char *  fmt,
  ... 
)

Definition at line 85 of file log.cpp.

86{
87 struct timespec tv;
88
89 double now = (double)sys_time() / (double)sys_ticksecond;
90 tv.tv_nsec = long(fmod(now, 1.0) * 1000000000.0f);
91 tv.tv_sec = (uint64_t)now;
92
93 printf("%s:%d %s %" PRIu64 ".%09ld ", file, line,
94 log_label(level),
95 (uint64_t)tv.tv_sec, tv.tv_nsec);
96
97 va_list args;
98 va_start(args, fmt);
99 vprintf(fmt, args);
100 va_end(args);
101
102 printf("\x1b[0m\n");
103
104}
uint64_t sys_time(void)
Definition: global.cpp:56
uint64_t sys_ticksecond
Definition: global.cpp:54

◆ testit()

void testit ( const char *  fmt,
  ... 
)

Definition at line 19 of file log.cpp.

20{
21
22 va_list args;
23 va_start(args, fmt);
24 vprintf(fmt, args);
25 va_end(args);
26
27 printf("\x1b[0m\n");
28
29}

◆ to_wchar()

std::wstring to_wchar ( const char *  text)
inline

Definition at line 203 of file log.cpp.

203 {
204 //const char* text_char = "example of mbstowcs";
205 size_t length = strlen(text);
206 std::wstring text_wchar(length, L'#');
207 //#pragma warning (disable : 4996)
208 // Or add to the preprocessor: _CRT_SECURE_NO_WARNINGS
209 mbstowcs(&text_wchar[0], text, length);
210 return text_wchar;
211};

Variable Documentation

◆ FilePrintOn

bool FilePrintOn
extern