@@ -63,3 +63,4 @@ cmake-build-debug/ | |||
assets_wip/ | |||
Backup_*.cdr | |||
.DS_Store | |||
*.sqlite |
@@ -346,14 +346,14 @@ IZ_ConfigInitializeResult IZ_ConfigInitialize(IZ_ConfigItem item[], const char* | |||
IZ_ConfigLoad(item, config_path); | |||
IZ_ConfigSaveResult save_result = IZ_ConfigSave(item, config_path); | |||
if (save_result < 0) { | |||
IZ_LogError("app/config Sync failed! Result: %u", save_result); | |||
IZ_LogError("config", "Sync failed! Result: %u", save_result); | |||
return IZ_CONFIG_INITIALIZE_RESULT_ERROR; | |||
} | |||
IZ_ConfigOverride(item, argc, argv); | |||
if (save_result > 0) { | |||
IZ_LogWarn(false, "app/config Sync encountered issues. Result: %u", save_result); | |||
IZ_LogWarn(false, "config", "Sync encountered issues. Result: %u", save_result); | |||
return IZ_CONFIG_INITIALIZE_RESULT_WARNING; | |||
} | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/config Sync successful."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "config", "Sync successful."); | |||
return IZ_CONFIG_INITIALIZE_RESULT_OK; | |||
} |
@@ -28,7 +28,7 @@ typedef enum { | |||
IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* argv[]) { | |||
IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/global Starting %s...", IZ_APP_NAME); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "global", "Starting %s...", IZ_APP_NAME); | |||
IZ_memset(app, 0, sizeof(struct IZ_App)); | |||
const char* cmdline_buffer; | |||
@@ -47,7 +47,7 @@ IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* | |||
); | |||
if (SDL_Init(flags) < 0) { | |||
IZ_LogError("app/global Framework initialization failed! Reason: %s", SDL_GetError()); | |||
IZ_LogError("global", "Framework initialization failed! Reason: %s", SDL_GetError()); | |||
return IZ_APP_INITIALIZE_RESULT_SDL_ERROR; | |||
} | |||
@@ -70,12 +70,12 @@ IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* | |||
} | |||
void IZ_AppTeardown(struct IZ_App* app) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/net Shutting down..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "net", "Shutting down..."); | |||
IZ_NetClientDisconnect(&app->net_state); | |||
IZ_PoolTeardown(&app->pool); | |||
IZ_InputTeardown(&app->input_state); | |||
IZ_VideoTeardown(&app->video_state); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/global Stopping %s...", IZ_APP_NAME); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "global", "Stopping %s...", IZ_APP_NAME); | |||
SDL_Quit(); | |||
} | |||
@@ -10,7 +10,7 @@ void IZ_InputHandlePortMIDIEvents(IZ_InputState* state, PmEvent e) { | |||
} | |||
IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_path, u8 argc, const char* argv[]) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Setting up..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Setting up..."); | |||
*state = (IZ_InputState) { | |||
.action = {}, | |||
@@ -40,13 +40,13 @@ IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_p | |||
IZ_ProcedureResult final_result = -result; | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Setup complete. Result: %d", final_result); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Setup complete. Result: %d", final_result); | |||
return final_result; | |||
} | |||
void IZ_InputTeardown(IZ_InputState* state) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/input Shutting down..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Shutting down..."); | |||
IZ_JoystickTeardown(&state->joystick_state); | |||
IZ_MIDIInputTeardown(&state->midi_input_state); | |||
} |
@@ -1,7 +1,7 @@ | |||
#include "IZ_pool.h" | |||
void IZ_PoolInitialize(IZ_Pool* pool, size_t size) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/memory Setting up pool..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "memory", "Setting up pool..."); | |||
IZ_ListInitialize(&pool->items); | |||
pool->memory = IZ_malloc(size); | |||
IZ_memset(pool->memory, 0, size); | |||
@@ -47,7 +47,7 @@ void IZ_PoolDeallocate(IZ_PoolItem* item) { | |||
} | |||
void IZ_PoolTeardown(IZ_Pool* pool) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/memory Shutting down pool..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "memory", "Shutting down pool..."); | |||
IZ_free(pool->memory); | |||
pool->memory = NULL; | |||
} |
@@ -65,7 +65,7 @@ IZ_ProcedureResult IZ_VideoInitializeConfig(IZ_VideoState* state, const char* c | |||
} | |||
IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, const char* config_path, u8 argc, const char* argv[]) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/video Setting up..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "video", "Setting up..."); | |||
IZ_memcpy(state, sizeof(IZ_VideoState), &IZ_VIDEO_DEFAULT_STATE, sizeof(IZ_VideoState)); | |||
IZ_memset(state->active_sprites, 0, sizeof(IZ_SpriteSlot) * IZ_MAX_ACTIVE_SPRITES); | |||
if (IZ_VideoInitializeConfig(state, config_path, argc, argv) < 0) { | |||
@@ -84,7 +84,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con | |||
SDL_WINDOW_SHOWN | |||
); | |||
if (window == NULL) { | |||
IZ_LogError("app/video Window could not be created! Reason: %s", SDL_GetError()); | |||
IZ_LogError("video", "Window could not be created! Reason: %s", SDL_GetError()); | |||
return -3; | |||
} | |||
state->window = window; | |||
@@ -93,7 +93,7 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con | |||
} | |||
void IZ_VideoTeardown(IZ_VideoState* state) { | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/video Shutting down..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "video", "Shutting down..."); | |||
for (u16 i = 0; i < IZ_MAX_ACTIVE_SPRITES; i += 1) { | |||
if (state->active_sprites[i].sprite.texture) { | |||
SDL_DestroyTexture(state->active_sprites[i].sprite.texture); | |||
@@ -56,20 +56,20 @@ void IZ_LogInterceptHandleFromWS(i32 level, const char* line) { | |||
switch (level) { | |||
// TODO level is a bit field...check if each level is OR'd. | |||
case LLL_ERR: | |||
IZ_LogError("app/net/ws %s", buffer); | |||
IZ_LogError("net/ws", "%s", buffer); | |||
return; | |||
case LLL_WARN: | |||
IZ_LogWarn(false, "app/net/ws %s", buffer); | |||
IZ_LogWarn(true, "net/ws", "%s", buffer); | |||
return; | |||
case LLL_NOTICE: | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GENERIC, "app/net/ws %s", buffer); | |||
IZ_LogWarn(false, "net/ws", "%s", buffer); | |||
return; | |||
case LLL_USER: | |||
default: | |||
break; | |||
} | |||
IZ_Log("app/net/ws %s", buffer); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GENERIC, "net/ws", "%s", buffer); | |||
} | |||
void IZ_LogInterceptWSMessages(i32 level) { | |||
@@ -40,7 +40,7 @@ bool IZ_LogIsSupportedColor() { | |||
#endif | |||
} | |||
void IZ_LogError(const char* fmt, ...) { | |||
void IZ_LogError(const char* context, const char* fmt, ...) { | |||
#ifdef IZ_LOG_LEVEL_FLAG_ERROR | |||
char buffer[4096]; | |||
va_list args; | |||
@@ -49,15 +49,15 @@ void IZ_LogError(const char* fmt, ...) { | |||
va_end(args); | |||
if (IZ_LogIsSupportedColor()) { | |||
fprintf(stdout, RED "%12s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, RED "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
return; | |||
} | |||
fprintf(stderr, "%12s" " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stderr, "%24s" " " "%-6s" " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
#endif | |||
} | |||
void IZ_LogInfo(IZ_LogCategory category, const char* fmt, ...) { | |||
void IZ_LogInfo(IZ_LogCategory category, const char* context, const char* fmt, ...) { | |||
#ifdef IZ_LOG_LEVEL_FLAG_INFO | |||
char buffer[4096]; | |||
va_list args; | |||
@@ -69,24 +69,24 @@ void IZ_LogInfo(IZ_LogCategory category, const char* fmt, ...) { | |||
switch (category) { | |||
default: | |||
case IZ_LOG_CATEGORY_GENERIC: | |||
fprintf(stdout, CYN "%12s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, CYN "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
break; | |||
case IZ_LOG_CATEGORY_GLOBAL: | |||
fprintf(stdout, MAG "%12s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, MAG "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
break; | |||
case IZ_LOG_CATEGORY_INPUT: | |||
fprintf(stdout, GRN "%12s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, WHT "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
break; | |||
} | |||
return; | |||
} | |||
fprintf(stdout, "%12s" " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, "%24s" " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
#endif | |||
} | |||
void IZ_LogWarn(bool is_critical, const char* fmt, ...) { | |||
void IZ_LogWarn(bool is_critical, const char* context, const char* fmt, ...) { | |||
#ifdef IZ_LOG_LEVEL_FLAG_WARN | |||
char buffer[4096]; | |||
va_list args; | |||
@@ -96,18 +96,18 @@ void IZ_LogWarn(bool is_critical, const char* fmt, ...) { | |||
if (IZ_LogIsSupportedColor()) { | |||
if (is_critical) { | |||
fprintf(stdout, WHT "%24s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, GRN "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
} else { | |||
fprintf(stdout, YEL "%24s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, YEL "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
} | |||
return; | |||
} | |||
fprintf(stdout, "%24s" " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, "%24s" " " "%-6s" " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
#endif | |||
} | |||
void IZ_Log(const char* fmt, ...) { | |||
void IZ_Log(const char* context, const char* fmt, ...) { | |||
#ifdef IZ_LOG_LEVEL_FLAG_DEBUG | |||
char buffer[4096]; | |||
va_list args; | |||
@@ -115,10 +115,10 @@ void IZ_Log(const char* fmt, ...) { | |||
vsnprintf(buffer, sizeof(buffer), fmt, args); | |||
va_end(args); | |||
if (IZ_LogIsSupportedColor()) { | |||
fprintf(stdout, BLU "%12s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, BLU "%24s" RESET " " BOLD "%-6s" RESET " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
return; | |||
} | |||
fprintf(stdout, "%12s" " %s\n", IZ_LOG_DATE_FUNCTION(), buffer); | |||
fprintf(stdout, "%24s" " " "%-6s" " %s\n", IZ_LOG_DATE_FUNCTION(), context, buffer); | |||
#endif | |||
} |
@@ -1,13 +1,14 @@ | |||
#ifndef IZ_LOG_H | |||
#define IZ_LOG_H | |||
#define RED "\x1B[31m" | |||
#define GRN "\x1B[32m" | |||
#define YEL "\x1B[33m" | |||
#define BLU "\x1B[34m" | |||
#define MAG "\x1B[35m" | |||
#define CYN "\x1B[36m" | |||
#define WHT "\x1B[37m" | |||
#define BOLD "\x1B[0;1m" // Bold White | |||
#define RED "\x1B[0;31m" | |||
#define GRN "\x1B[0;32m" | |||
#define YEL "\x1B[0;33m" | |||
#define BLU "\x1B[0;34m" | |||
#define MAG "\x1B[0;35m" | |||
#define CYN "\x1B[0;36m" | |||
#define WHT "\x1B[0;37m" | |||
#define RESET "\x1B[0m" | |||
#define IZ_LOG_LEVEL_FLAG_DEBUG | |||
@@ -28,9 +29,9 @@ typedef enum { | |||
IZ_LOG_CATEGORY_GENERIC, | |||
} IZ_LogCategory; | |||
void IZ_LogError(const char* fmt, ...); | |||
void IZ_LogInfo(IZ_LogCategory category, const char* fmt, ...); | |||
void IZ_LogWarn(bool is_critical, const char* fmt, ...); | |||
void IZ_Log(const char* fmt, ...); | |||
void IZ_LogError(const char* context, const char* fmt, ...); | |||
void IZ_LogInfo(IZ_LogCategory category, const char* context, const char* fmt, ...); | |||
void IZ_LogWarn(bool is_critical, const char* context, const char* fmt, ...); | |||
void IZ_Log(const char* context, const char* fmt, ...); | |||
#endif |
@@ -106,7 +106,7 @@ IZ_ProcedureResult IZ_NetClientInitialize( | |||
if (!user_data) { | |||
return -1; | |||
} | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "app/net Setting up..."); | |||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "net", "Setting up..."); | |||
IZ_memcpy(state, sizeof(IZ_NetClientState), &IZ_NET_CLIENT_DEFAULT_STATE, sizeof(IZ_NetClientState)); | |||
if (IZ_NetClientInitializeConfig(state, config_path, argc, argv) < 0) { | |||
return -2; | |||