From 8d1de1b24c232a4da58c8b30846f022820528d4c Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 23 Jul 2025 14:06:17 -0700 Subject: [PATCH] report user errors from ctrl thread more vigorously --- src/ctrl/ctrl_core.c | 29 +++++++++++------------------ src/ctrl/ctrl_core.h | 5 ++--- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 9815847c..bbebf606 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -3868,16 +3868,7 @@ ctrl_thread__entry_point(void *p) ins_atomic_u64_inc_eval(&ctrl_state->reg_gen); //- rjf: gather & output logs - LogScopeResult log = log_scope_end(scratch.arena); - ctrl_thread__flush_info_log(log.strings[LogMsgKind_Info]); - if(log.strings[LogMsgKind_UserError].size != 0) - { - CTRL_EventList evts = {0}; - CTRL_Event *evt = ctrl_event_list_push(scratch.arena, &evts); - evt->kind = CTRL_EventKind_Error; - evt->string = log.strings[LogMsgKind_UserError]; - ctrl_c2u_push_events(&evts); - } + ctrl_thread__end_and_flush_log(); } scratch_end(scratch); @@ -5279,17 +5270,19 @@ ctrl_thread__eval_scope_end(CTRL_EvalScope *scope) //- rjf: log flusher internal void -ctrl_thread__flush_info_log(String8 string) -{ - os_append_data_to_file_path(ctrl_state->ctrl_thread_log_path, string); -} - -internal void -ctrl_thread__end_and_flush_info_log(void) +ctrl_thread__end_and_flush_log(void) { Temp scratch = scratch_begin(0, 0); LogScopeResult log = log_scope_end(scratch.arena); - ctrl_thread__flush_info_log(log.strings[LogMsgKind_Info]); + os_append_data_to_file_path(ctrl_state->ctrl_thread_log_path, log.strings[LogMsgKind_Info]); + if(log.strings[LogMsgKind_UserError].size != 0) + { + CTRL_EventList evts = {0}; + CTRL_Event *evt = ctrl_event_list_push(scratch.arena, &evts); + evt->kind = CTRL_EventKind_Error; + evt->string = log.strings[LogMsgKind_UserError]; + ctrl_c2u_push_events(&evts); + } scratch_end(scratch); } diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index e3f785cd..d31a5e1b 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -873,7 +873,7 @@ thread_static CTRL_EntityCtxLookupAccel *ctrl_entity_ctx_lookup_accel = 0; //////////////////////////////// //~ rjf: Logging Markup -#define CTRL_CtrlThreadLogScope DeferLoop(log_scope_begin(), ctrl_thread__end_and_flush_info_log()) +#define CTRL_CtrlThreadLogScope DeferLoop(log_scope_begin(), ctrl_thread__end_and_flush_log()) //////////////////////////////// //~ rjf: Basic Type Functions @@ -1124,8 +1124,7 @@ internal CTRL_EvalScope *ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBr internal void ctrl_thread__eval_scope_end(CTRL_EvalScope *scope); //- rjf: log flusher -internal void ctrl_thread__flush_info_log(String8 string); -internal void ctrl_thread__end_and_flush_info_log(void); +internal void ctrl_thread__end_and_flush_log(void); //- rjf: msg kind implementations internal void ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg);