Fixed leaky imports, modified log stuff

This commit is contained in:
Krzosa Karol
2022-10-11 10:20:18 +02:00
parent 977a62d5ae
commit 4004b8b8d3
8 changed files with 67 additions and 41 deletions

View File

@@ -561,7 +561,7 @@ arena_init(Arena *a, String debug_name){
a->debug_string = debug_name;
}
enum Log_Kind{Log_Kind_Normal, Log_Kind_Error, Log_Kind_Trace};
enum Log_Kind{Log_Kind_Normal_No_NewLine, Log_Kind_Normal, Log_Kind_Error, Log_Kind_Trace};
typedef void Log_Proc(Log_Kind kind, String string, char *file, int line);
//-----------------------------------------------------------------------------
// Thread Context
@@ -753,6 +753,7 @@ array_make(Arena *a, S64 size = 16){
// Logging
//-----------------------------------------------------------------------------
#define log_info(...) handle_log_message(Log_Kind_Normal, __LINE__, __FILE__,##__VA_ARGS__)
#define log_info_no_nl(...) handle_log_message(Log_Kind_Normal_No_NewLine, __LINE__, __FILE__,##__VA_ARGS__)
#define log_trace(...) handle_log_message(Log_Kind_Trace, __LINE__, __FILE__,##__VA_ARGS__)
#define log_error(...) handle_log_message(Log_Kind_Error, __LINE__, __FILE__,##__VA_ARGS__)
function void
@@ -764,6 +765,9 @@ handle_log_message(Log_Kind kind, int line, const char *file, const char *str, .
if(thread_ctx.log_proc) thread_ctx.log_proc(kind, message, (char *)file, line);
else{
printf("%s", message.str);
if(kind != Log_Kind_Normal_No_NewLine){
printf("\n");
}
}
}