remove date from core, app_wasm.html

This commit is contained in:
krzosa
2025-01-04 08:38:19 +01:00
parent 1fca44fcfc
commit 6f795b7ea6
14 changed files with 208 additions and 82 deletions

View File

@@ -23,26 +23,9 @@ fn void log_basef(i32 module, log_level_t level, s8_t file_and_line, const char
fn void default_log_proc(log_event_t ev) {
ma_temp_t scratch = ma_begin_scratch();
sb8_t *sb = sb8_serial_begin(scratch.arena);
if (tcx.log.flags & log_flag_module_id) {
sb8_printf(sb, "[%d] ", ev.module);
}
if (tcx.log.flags & log_flag_level) {
sb8_printf(sb, "%-5s ", log_level_str(ev.level));
}
date_t date = {0};
{
b32 bdate = (tcx.log.flags & log_flag_date);
b32 btime = (tcx.log.flags & log_flag_time);
if (bdate || btime) {
date = os_date_now();
}
if (bdate) {
sb8_printf(sb, "%04u.%02u.%02u ", date.year, date.month, date.day);
}
if (btime) {
sb8_printf(sb, "%02u:%02u:%02u ", date.hour, date.min, date.sec);
}
}
if (tcx.log.flags & log_flag_file_path) {
sb8_printf(sb, "%S: ", ev.file_and_line);
}

View File

@@ -21,11 +21,8 @@ const i32 module_null = 0;
typedef enum {
log_flag_null = 0,
log_flag_level = 1,
log_flag_date = 2,
log_flag_time = 4,
log_flag_file_path = 8,
log_flag_module_id = 16,
log_flag_all = log_flag_level | log_flag_date | log_flag_time | log_flag_file_path | log_flag_module_id,
log_flag_all = log_flag_level | log_flag_file_path,
} log_flag_t;
typedef enum { // AFTER_CHANGING: modify type_info and log_level_str

View File

@@ -1,18 +1,5 @@
typedef struct date_t date_t;
struct date_t {
u16 ms;
u16 sec;
u16 min;
u16 hour;
u16 day;
u16 month;
u16 year;
};
fn void os_error_box(char *str);
fn void os_console_log(char *str);
fn date_t os_date_now(void);
fn f64 os_milliseconds_now(void);
fn void *os_vmem_reserve(usize size);
fn b32 os_vmem_commit(void *p, usize size);

View File

@@ -19,19 +19,6 @@ fn b32 os_vmem_decommit(void *p, usize size) {
return true;
}
fn date_t os_date_now(void) {
date_t result = {0};
time_t time = time(NULL);
struct tm *lt = localtime(&time);
result.sec = lt->tm_sec;
result.min = lt->tm_min;
result.hour = lt->tm_hour;
result.day = lt->tm_mday;
result.month = lt->tm_month;
result.year = lt->tm_year;
return result;
}
fn void os_error_box(char *str) {
fprintf(stderr, "%s", str);
}

View File

@@ -1,7 +1,6 @@
fn_wasm_import void wasm_alert(isize ptr, i32 len);
fn_wasm_import f64 wasm_parse_float(isize str, i32 len);
fn_wasm_import void wasm_write_to_console(isize str, i32 len);
fn_wasm_import f64 wasm_get_milliseconds(void);
extern char __heap_base;
@@ -21,11 +20,6 @@ fn b32 os_vmem_decommit(void *p, usize size) {
return true;
}
fn date_t os_date_now(void) {
date_t result = {0}; // don't need timed logs in browser
return result;
}
fn void os_error_box(char *str) {
wasm_alert((isize)str, str_len(str));
}

View File

@@ -7,7 +7,6 @@ fn b32 os_vmem_commit(void *p, usize size) {
void *result = VirtualAlloc(p, size, MEM_COMMIT, PAGE_READWRITE);
return result ? true : false;
}
fn b32 os_vmem_release(void *p) {
BOOL result = VirtualFree(p, 0, MEM_RELEASE);
return result ? true : false;
@@ -18,20 +17,6 @@ fn b32 os_vmem_decommit(void *p, usize size) {
return result ? true : false;
}
fn date_t os_date_now(void) {
date_t result = {0};
SYSTEMTIME lt;
GetLocalTime(&lt);
result.ms = lt.wMilliseconds;
result.sec = lt.wSecond;
result.min = lt.wMinute;
result.hour = lt.wHour;
result.day = lt.wDay;
result.month = lt.wMonth;
result.year = lt.wYear;
return result;
}
fn void os_error_box(char *str) {
MessageBoxA(NULL, str, "fatal error", MB_OK);
fprintf(stderr, "%s", str);