-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.cpp
More file actions
25 lines (19 loc) · 745 Bytes
/
log.cpp
File metadata and controls
25 lines (19 loc) · 745 Bytes
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
#include"log.h"
void logMessageFromCpp(const char *message) {
qDebug() << "C++ Log:" << message;
}
void logMessageFromCppFormat(const char *__format, ...) {
char logbuf[256]; // Larger buffer to accommodate formatted strings
memset(logbuf, 0, sizeof(logbuf));
// Start variadic argument processing
va_list args;
va_start(args, __format);
// Use vsnprintf for safety (to avoid buffer overflow)
vsnprintf(logbuf, sizeof(logbuf), __format, args);
// End variadic argument processing
va_end(args);
// Log the formatted message using qDebug and logMessageFromCpp
qDebug() << "game Log:" << logbuf;
// Optionally, call another logging function (if needed)
// logMessageFromCpp(logbuf);
}