Remove usage of do in core library

This commit is contained in:
gingerBill
2020-09-23 17:17:14 +01:00
parent 4844dd4d96
commit fc4fdd588e
45 changed files with 960 additions and 520 deletions
+18 -7
View File
@@ -43,7 +43,9 @@ create_file_logger :: proc(h: os.Handle, lowest := Level.Debug, opt := Default_F
destroy_file_logger :: proc(log: ^Logger) {
data := cast(^File_Console_Logger_Data)log.data;
if data.file_handle != os.INVALID_HANDLE do os.close(data.file_handle);
if data.file_handle != os.INVALID_HANDLE {
os.close(data.file_handle);
}
free(data);
}
@@ -75,8 +77,8 @@ file_console_logger_proc :: proc(logger_data: rawptr, level: Level, text: string
t := time.now();
y, m, d := time.date(t);
h, min, s := time.clock(t);
if .Date in options do fmt.sbprintf(&buf, "%d-%02d-%02d ", y, m, d);
if .Time in options do fmt.sbprintf(&buf, "%02d:%02d:%02d", h, min, s);
if .Date in options { fmt.sbprintf(&buf, "%d-%02d-%02d ", y, m, d); }
if .Time in options { fmt.sbprintf(&buf, "%02d:%02d:%02d", h, min, s); }
fmt.sbprint(&buf, "] ");
}
}
@@ -89,7 +91,9 @@ file_console_logger_proc :: proc(logger_data: rawptr, level: Level, text: string
fmt.sbprintf(&buf, "[{}] ", os.current_thread_id());
}
if data.ident != "" do fmt.sbprintf(&buf, "[%s] ", data.ident);
if data.ident != "" {
fmt.sbprintf(&buf, "[%s] ", data.ident);
}
//TODO(Hoej): When we have better atomics and such, make this thread-safe
fmt.fprintf(h, "%s %s\n", strings.to_string(buf), text);
}
@@ -110,14 +114,21 @@ do_level_header :: proc(opts: Options, level: Level, str: ^strings.Builder) {
}
if .Level in opts {
if .Terminal_Color in opts do fmt.sbprint(str, col);
if .Terminal_Color in opts {
fmt.sbprint(str, col);
}
fmt.sbprint(str, Level_Headers[level]);
if .Terminal_Color in opts do fmt.sbprint(str, RESET);
if .Terminal_Color in opts {
fmt.sbprint(str, RESET);
}
}
}
do_location_header :: proc(opts: Options, buf: ^strings.Builder, location := #caller_location) {
if Location_Header_Opts & opts != nil do fmt.sbprint(buf, "["); else do return;
if Location_Header_Opts & opts == nil {
return;
}
fmt.sbprint(buf, "[");
file := location.file_path;
if .Short_File_Path in opts {