log: flush buffers after assert failure
This commit is contained in:
parent
efe8370845
commit
7c19322940
4 changed files with 11 additions and 5 deletions
|
@ -309,7 +309,7 @@ bool dynstage_reload_library(void) {
|
|||
if(dynstage.lib) {
|
||||
// In-flight async log messages may still have pointers to static strings inside the old lib
|
||||
// Wait for them to finish processing so it's safe to unload
|
||||
log_sync();
|
||||
log_sync(false);
|
||||
|
||||
dlclose(dynstage.lib);
|
||||
}
|
||||
|
|
10
src/log.c
10
src/log.c
|
@ -452,11 +452,17 @@ void log_shutdown(void) {
|
|||
memset(&logging, 0, sizeof(logging));
|
||||
}
|
||||
|
||||
void log_sync(void) {
|
||||
void log_sync(bool flush) {
|
||||
SDL_LockMutex(logging.queue.mutex);
|
||||
while(logging.queue.queue.first) {
|
||||
|
||||
while(logging.queue.queue.first) {
|
||||
SDL_CondWait(logging.queue.cond, logging.queue.mutex);
|
||||
}
|
||||
|
||||
if(flush) {
|
||||
list_foreach(&logging.outputs, sync_logger, NULL);
|
||||
}
|
||||
|
||||
SDL_UnlockMutex(logging.queue.mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ LogLevelDiff log_merge_level_diff(LogLevelDiff lower, LogLevelDiff upper) attr_n
|
|||
LogLevel log_apply_level_diff(LogLevel lvls, LogLevelDiff diff) attr_nodiscard;
|
||||
bool log_initialized(void) attr_nodiscard;
|
||||
void log_set_gui_error_appendix(const char *message);
|
||||
void log_sync(void);
|
||||
void log_sync(bool flush);
|
||||
void log_add_filter(LogLevelDiff diff, const char *pmod, const char *pfunc);
|
||||
bool log_add_filter_string(const char *fstr);
|
||||
void log_remove_filters(void);
|
||||
|
|
|
@ -17,7 +17,7 @@ void _ts_assert_fail(const char *cond, const char *func, const char *file, int l
|
|||
|
||||
if(use_log) {
|
||||
_taisei_log(LOG_FAKEFATAL, func, file, line, "%s:%i: assertion `%s` failed", file, line, cond);
|
||||
log_sync();
|
||||
log_sync(true);
|
||||
} else {
|
||||
tsfprintf(stderr, "%s:%i: %s(): assertion `%s` failed\n", file, line, func, cond);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue