Improve logging output
This commit is contained in:
1 parent
7ca73f3c60
commit
3a58bd8756
3 files changed
+6
-5
No files matched your search
@@ -143,7 +143,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debug_callback(VkDebugUtilsMessageSeverityFlagBit
|
|||||||
(void)message_type;
|
(void)message_type;
|
||||||
(void)user_data;
|
(void)user_data;
|
||||||
|
|
||||||
fprintf(stderr, "validation layer: %s\n", callback_data->pMessage);
|
LOGD(callback_data->pMessage);
|
||||||
|
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -17,9 +17,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||||
#define LOGGER(log_level, ...) _log_log(log_level, __FILE__, __LINE__, __VA_ARGS__)
|
#define LOGGER(log_level, ...) _log_log(log_level, __FILENAME__, __LINE__, __VA_ARGS__)
|
||||||
// #define LOGGER(log_level, ...) printf("[##log_level] %s:%d", __FILE__, __LINE__); printf(__VA_ARGS__)
|
// #define LOGGER(log_level, ...) printf("[##log_level] %s:%d", __FILE__, __LINE__); printf(__VA_ARGS__)
|
||||||
|
|
||||||
#define LOGT(...) LOGGER(LOGLEVEL_TRACE, __VA_ARGS__)
|
#define LOGT(...) LOGGER(LOGLEVEL_TRACE, __VA_ARGS__)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
|
|
||||||
const char* log_levels[] = {
|
const char* log_levels[] = {
|
||||||
"LOGLEVEL_TRACE", "LOGLEVEL_DEBUG", "LOGLEVEL_INFO", "LOGLEVEL_WARNING", "LOGLEVEL_ERROR", "LOGLEVEL_FATAL"
|
"[TRACE]", "[DEBUG]", "[INFO]", "WARNING", "[ERROR]", "[FATAL]"
|
||||||
};
|
};
|
||||||
|
|
||||||
void _log_log(unsigned int level, const char* file, int line, const char* fmt, ...)
|
void _log_log(unsigned int level, const char* file, int line, const char* fmt, ...)
|
||||||
@@ -11,7 +11,7 @@ void _log_log(unsigned int level, const char* file, int line, const char* fmt, .
|
|||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
fprintf(stdout, "%s %s:%d ", log_levels[level], file, line);
|
fprintf(stdout, "%s %s:%d: ", log_levels[level], file, line);
|
||||||
vfprintf(stdout, fmt, list);
|
vfprintf(stdout, fmt, list);
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Reference in new issue
Block a user