mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-04-19 16:17:34 -05:00
feat(inject): Use async log sink for logging
Solves similar issues with the old games not using the AVS logging system (because there is none). Threads calling the log functions are still logging using OutputDebugStr, but the dispatching in the debugger module in inject hands those messages off to the async log sink which avoids blocking the calling thread (for long). We want to keep this feature around as there are several games actually having non-removed OutputDebugStr calls which can provide some useful debugging information. Furthermore, neutral hooks only using DllMain and not the bemanitools API can still channel log messages this way to bemanitools’s logging system (though less efficiently than calling it directly). Further changes to existing hooks will be applied to migrate their logger usage to using the logger directly through the bemanitools API.
This commit is contained in:
parent
8bb8c3364e
commit
27e9f8dea8
|
|
@ -53,25 +53,12 @@ static void _inject_log_header()
|
|||
void _inject_log_init(
|
||||
const char *log_file_path, enum core_log_bt_log_level level)
|
||||
{
|
||||
core_log_sink_t sinks[2];
|
||||
core_log_sink_t sink_composed;
|
||||
core_log_sink_t sink_mutex;
|
||||
|
||||
if (log_file_path) {
|
||||
core_log_sink_std_out_open(true, &sinks[0]);
|
||||
core_log_sink_file_open(log_file_path, false, true, 10, &sinks[1]);
|
||||
core_log_sink_list_open(sinks, 2, &sink_composed);
|
||||
core_log_bt_ext_init_async_with_stderr_and_file(log_file_path, false, true, 10);
|
||||
} else {
|
||||
core_log_sink_std_out_open(true, &sink_composed);
|
||||
core_log_bt_ext_init_async_with_stderr();
|
||||
}
|
||||
|
||||
// Different threads logging the same destination, e.g. debugger thread,
|
||||
// main thread
|
||||
// TODO this needs to be de-coupled with async logging to fix latency
|
||||
// issues for any game related threads logging
|
||||
core_log_sink_mutex_open(&sink_composed, &sink_mutex);
|
||||
|
||||
core_log_bt_init(&sink_mutex);
|
||||
core_log_bt_core_api_set();
|
||||
|
||||
core_log_bt_level_set(level);
|
||||
|
|
@ -217,6 +204,8 @@ int main(int argc, char **argv)
|
|||
goto init_options_fail;
|
||||
}
|
||||
|
||||
core_thread_crt_core_api_set();
|
||||
|
||||
// TODO expose log level
|
||||
_inject_log_init(
|
||||
strlen(options.log_file) > 0 ? options.log_file : NULL,
|
||||
|
|
@ -225,8 +214,6 @@ int main(int argc, char **argv)
|
|||
_inject_log_header();
|
||||
os_version_log();
|
||||
|
||||
core_thread_crt_core_api_set();
|
||||
|
||||
signal_exception_handler_init();
|
||||
// Cleanup remote process on CTRL+C
|
||||
signal_register_shutdown_handler(signal_shutdown_handler);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user