Added info and warn log levels.

This commit is contained in:
2021-06-09 19:52:02 +02:00
parent 1a54147c69
commit ad33883c35
3 changed files with 23 additions and 4 deletions

View File

@@ -19,11 +19,23 @@ void vkeSetLogLevel(int level) {
} }
void vkeLogDebug(const char* message) { void vkeLogDebug(const char* message) {
if(logLevel < VKE_LOG_ERROR) { if(logLevel < VKE_LOG_INFO) {
printf("%s [DEBUG] %s\n", timeNow(), message); printf("%s [DEBUG] %s\n", timeNow(), message);
} }
} }
void vkeLogInfo(const char* message) {
if(logLevel < VKE_LOG_WARN) {
printf("%s [INFO] %s\n", timeNow(), message);
}
}
void vkeLogWarn(const char* message) {
if(logLevel < VKE_LOG_ERROR) {
printf("%s [WARN] %s\n", timeNow(), message);
}
}
void vkeLogError(const char* message) { void vkeLogError(const char* message) {
if(logLevel < VKE_LOG_ERROR+1) { if(logLevel < VKE_LOG_ERROR+1) {
printf("%s [ERROR] %s\n", timeNow(), message); printf("%s [ERROR] %s\n", timeNow(), message);

View File

@@ -2,6 +2,8 @@
#define VKE_LOG_H #define VKE_LOG_H
#define VKE_LOG_DEBUG 0 #define VKE_LOG_DEBUG 0
#define VKE_LOG_INFO 0
#define VKE_LOG_WARN 0
#define VKE_LOG_ERROR 1 #define VKE_LOG_ERROR 1
// Sets the global log level (VKE_LOG_DEBUG by default). // Sets the global log level (VKE_LOG_DEBUG by default).
@@ -10,6 +12,12 @@ void vkeSetLogLevel(int level);
// Logs the given message with the DEBUG tag. // Logs the given message with the DEBUG tag.
void vkeLogDebug(const char* message); void vkeLogDebug(const char* message);
// Logs the given message with the INFO tag.
void vkeLogInfo(const char* message);
// Logs the given message with the WARN tag.
void vkeLogWarn(const char* message);
// Logs the given message with the ERROR tag. // Logs the given message with the ERROR tag.
void vkeLogError(const char* message); void vkeLogError(const char* message);

View File

@@ -74,11 +74,10 @@ int vkeInit(struct VKEContext* ctx, struct VKEConfig* config) {
.pApplicationInfo = &appInfo .pApplicationInfo = &appInfo
}; };
// TODO if(config->validationLayerCount > 0) {
/*if(config->validationLayerCount > 0) {
createInfo.enabledLayerCount = config->validationLayerCount; createInfo.enabledLayerCount = config->validationLayerCount;
createInfo.ppEnabledExtensionNames = config->validationLayers; createInfo.ppEnabledExtensionNames = config->validationLayers;
}*/ }
if(vkCreateInstance(&createInfo, NULL, &ctx->instance) != VK_SUCCESS) { if(vkCreateInstance(&createInfo, NULL, &ctx->instance) != VK_SUCCESS) {
vkeLogError("error creating vulkan instance\n"); vkeLogError("error creating vulkan instance\n");