diff --git a/.efrocachemap b/.efrocachemap index a393ee2b..a2eea1a7 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4096,56 +4096,56 @@ "build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1", "build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae", "build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "a598766836cd0ea28a1943b5dfa2cf48", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "2c7d6f8355451598be474d7ea7461ac4", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "f738c276faf69ac6b23b46a0e00e66cc", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "4f917646e3626fd49943b2f681e8bc27", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "2d044a28fd391fcf6e2c807c0fe51cbf", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "6974a7ba1384719ff3f34c5eacc6a2a4", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "382cf2436d7c488a6a20758e3d3c1f2b", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "ee990132a12cca7877c341399b7b8deb", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "27a952ea3647eca2b7ef0395409aa676", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "c181d7b07f9120502b3a88c949e99e3c", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "6530013d13781cb7f29a107df54f362c", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "c18fec69637b72f98a617cb22f0f0df7", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "04b70eb5f8f6bb0e07a4f3025903bda6", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "ad9ef6d83fa478ee9d1a40f61ca38730", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "f43917836334f3bc0277cbff0503878c", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "0dcf8315c0b8cc2da817e80d0577197b", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "3812999bfbc14ec860e49317c69aeb64", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "59da09b01e23f080569ee0e59483479c", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "e0992d0954ba8d3a74d332f535676cde", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "aa5256e587f4b93bc1ef988308a84113", - "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "51e81607756f0dca35b4aad4a183e82f", - "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "1e18027d82990576b97b02dc4bb0fb01", - "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "51e81607756f0dca35b4aad4a183e82f", - "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "1e18027d82990576b97b02dc4bb0fb01", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "b791b77e04bd1459487ced079b8875d8", - "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "8863c430ff6c2a11670c655ba35ccfc4", - "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "b791b77e04bd1459487ced079b8875d8", - "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "8863c430ff6c2a11670c655ba35ccfc4", - "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "8e6da834224087d2b773ddc8890c768e", - "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "a6f99bc0b4a5bcfdbe56941845622777", - "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "8e6da834224087d2b773ddc8890c768e", - "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "a6f99bc0b4a5bcfdbe56941845622777", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "a79716311cc136c207d979ad2a6b6e98", - "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "e602fad2ea96f7d026f3f8c20773e931", - "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "bc134f0972102db689dffd422ac97621", - "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "e602fad2ea96f7d026f3f8c20773e931", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "de9a96c4f76bb7c44329b95d8666a87d", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "7f746ad4356d533c12838b7ac9305ba1", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "33893747ea446f83a87f144ee8965799", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "e4d6245e0f25579ddc99c7aba78141d5", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "a686e191d9d3a7d36a62f101a823b08c", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "048e8dd6a7f783479ebb3ad3bfa92c65", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "a8fcea1b40352e73fc3b7ad87820c06b", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "264f656b3cc167f4bfe797f4a579b0f5", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "059baedbe0b66d30d0aa6689da4d63f3", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "3ed7b000a1ab91e479752a3888c83667", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "36c737e7702d8c06bc4fd2cfb07da351", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "6f487cdb9ba97fab91f04146afafe7dd", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "2c65291868c5d663aed8e091b3918560", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "907e310432844bc1a81e16cf2520e9b3", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "057e48bb93965e035ce5a41f86efef46", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "3a0831e5e874d7dae4698c726c522a27", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "5510a4efe5876817d7378f4c7c7eeb34", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "40535aed4289ab6c6cb2b1fb2756c510", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "762777a4a85b1306fb7cc66de9fe930f", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "4559fca91a2e663714f65c88960a8550", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "d9b8e42c9a51b803d7fd8d79b0c1089a", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "2bbda26d94f3c42eb50ae38f36736c41", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "28501bcf6678e9828b7c93d7124cb895", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "6f333b02870caea43e8b47b751e31c41", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "8df10a5d0119225f0ed1168380df70db", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "354f163cc24b1196fcf43c2949c7cabe", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "064aa919dda3f74787751c4c82133bd8", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "36eeeac892119b8080c99e8cc97ed825", + "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "8390ede3c9748e859f23db258289abf5", + "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "8361f4adc958e914301959ca55680fd5", + "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "8390ede3c9748e859f23db258289abf5", + "build/prefab/lib/linux_arm64_server/release/libballisticaplus.a": "8361f4adc958e914301959ca55680fd5", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticaplus.a": "5149cfef7284e1ba8ca9ec9cae4070a5", + "build/prefab/lib/linux_x86_64_gui/release/libballisticaplus.a": "4f5a0efc253ad90fb543214449b853f8", + "build/prefab/lib/linux_x86_64_server/debug/libballisticaplus.a": "5149cfef7284e1ba8ca9ec9cae4070a5", + "build/prefab/lib/linux_x86_64_server/release/libballisticaplus.a": "4f5a0efc253ad90fb543214449b853f8", + "build/prefab/lib/mac_arm64_gui/debug/libballisticaplus.a": "6f0409237172a162c07e3c413d2969ab", + "build/prefab/lib/mac_arm64_gui/release/libballisticaplus.a": "d11a17346662df85b844afa7bc1afb56", + "build/prefab/lib/mac_arm64_server/debug/libballisticaplus.a": "6f0409237172a162c07e3c413d2969ab", + "build/prefab/lib/mac_arm64_server/release/libballisticaplus.a": "d11a17346662df85b844afa7bc1afb56", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticaplus.a": "2a0eb5631a45c5724713e5e6cdc2b06e", + "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "af3468e5de5a0c2cb4e431239a5c0f2d", + "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "2405fb09f9d1f85f23f6ea3734913aa3", + "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "af3468e5de5a0c2cb4e431239a5c0f2d", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "000e8ab249264b6757fe9a5d80ac2954", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "9c37a69f926d48fc442e4fce842db161", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "e135d9e45e063a6eae61b8d8e621452e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "edae00044408aeb1e2c8bf8df14dbbec", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "78b57913e94e8106c443b15b14264c43", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "1d1dc16cc03ba9ed0330cf3e2d069b94", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "25aaf8090719e05b7a76a0c9cd10f6d1", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "e3593efe1a6c48977d70bc51f72e419e", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "794d258d59fd17a61752843a9a0551ad", "src/ballistica/base/mgen/pyembed/binding_base.inc": "efa61468cf098f77cc6a234461d8b86d", "src/ballistica/base/mgen/pyembed/binding_base_app.inc": "f0f9dc33ecd4ef7a384f131d62c96c97", "src/ballistica/classic/mgen/pyembed/binding_classic.inc": "3ceb412513963f0818ab39c58bf292e3", - "src/ballistica/core/mgen/pyembed/binding_core.inc": "3afbd58f56fd04bdd6fc2aa7ae166275", + "src/ballistica/core/mgen/pyembed/binding_core.inc": "02bf828e423d0fced4d87aa74f25cbdc", "src/ballistica/core/mgen/pyembed/env.inc": "f015d726b44d2922112fc14d9f146d8b", "src/ballistica/core/mgen/python_modules_monolithic.h": "fb967ed1c7db0c77d8deb4f00a7103c5", "src/ballistica/scene_v1/mgen/pyembed/binding_scene_v1.inc": "c25b263f2a31fb5ebe057db07d144879", diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ddea799..949b149e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.37 (build 22052, api 9, 2024-10-21) +### 1.7.37 (build 22057, api 9, 2024-10-22) - Bumping api version to 9. As you'll see below, there's some UI changes that will require a bit of work for any UI mods to adapt to. If your mods don't touch UI stuff at all you can simply bump your api version and call it a day. diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index d4c5cd5d..fbabfb34 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -53,7 +53,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 22052 +TARGET_BALLISTICA_BUILD = 22057 TARGET_BALLISTICA_VERSION = '1.7.37' diff --git a/src/ballistica/base/app_adapter/app_adapter_sdl.cc b/src/ballistica/base/app_adapter/app_adapter_sdl.cc index 9ca734da..c8397f6c 100644 --- a/src/ballistica/base/app_adapter/app_adapter_sdl.cc +++ b/src/ballistica/base/app_adapter/app_adapter_sdl.cc @@ -61,9 +61,9 @@ void AppAdapterSDL::OnMainThreadStartApp() { uint32_t sdl_flags{SDL_INIT_VIDEO | SDL_INIT_JOYSTICK}; if (strict_graphics_context_) { - Log(LogName::kBaNetworking, LogLevel::kWarning, - "AppAdapterSDL strict_graphics_context_ is enabled." - " Remember to turn this off."); + g_core->Log(LogName::kBaNetworking, LogLevel::kWarning, + "AppAdapterSDL strict_graphics_context_ is enabled." + " Remember to turn this off."); } // We may or may not want xinput on windows. @@ -309,8 +309,8 @@ void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) { const microsecs_t min_sleep{2000}; if (now + min_sleep >= target_time) { if (debug_log_sdl_frame_timing_) { - Log(LogName::kBaNetworking, LogLevel::kDebug, - "no sleep."); // 'till brooklyn! + g_core->Log(LogName::kBaNetworking, LogLevel::kDebug, + "no sleep."); // 'till brooklyn! } } else { if (debug_log_sdl_frame_timing_) { @@ -318,7 +318,7 @@ void AppAdapterSDL::SleepUntilNextEventCycle_(microsecs_t cycle_start_time) { snprintf(buf, sizeof(buf), "render %.1f sleep %.1f", (now - cycle_start_time) / 1000.0f, (target_time - now) / 1000.0f); - Log(LogName::kBaNetworking, LogLevel::kDebug, buf); + g_core->Log(LogName::kBaNetworking, LogLevel::kDebug, buf); } g_core->platform->SleepMicrosecs(target_time - now); } @@ -376,9 +376,9 @@ void AppAdapterSDL::HandleSDLEvent_(const SDL_Event& event) { g_base->input->PushJoystickEvent(event, js); } } else { - Log(LogName::kBaInput, LogLevel::kError, - "Unable to get SDL Joystick for event type " - + std::to_string(event.type)); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Unable to get SDL Joystick for event type " + + std::to_string(event.type)); } break; } @@ -565,10 +565,10 @@ void AppAdapterSDL::OnSDLJoystickAdded_(int device_index) { try { j = Object::NewDeferred(device_index); } catch (const std::exception& exc) { - Log(LogName::kBaInput, LogLevel::kError, - std::string("Error creating JoystickInput for SDL device-index " - + std::to_string(device_index) + ": ") - + exc.what()); + g_core->Log(LogName::kBaInput, LogLevel::kError, + std::string("Error creating JoystickInput for SDL device-index " + + std::to_string(device_index) + ": ") + + exc.what()); return; } assert(j != nullptr); @@ -604,7 +604,8 @@ void AppAdapterSDL::RemoveSDLInputDevice_(int index) { // Note: am running into this with a PS5 controller on macOS Sequoia beta. if (!j) { - Log(LogName::kBaInput, LogLevel::kError, + g_core->Log( + LogName::kBaInput, LogLevel::kError, "GetSDLJoystickInput_() returned nullptr on RemoveSDLInputDevice_();" " joysticks size is " + std::to_string(sdl_joysticks_.size()) + "; index is " @@ -616,10 +617,10 @@ void AppAdapterSDL::RemoveSDLInputDevice_(int index) { if (static_cast_check_fit(sdl_joysticks_.size()) > index) { sdl_joysticks_[index] = nullptr; } else { - Log(LogName::kBaInput, LogLevel::kError, - "Invalid index on RemoveSDLInputDevice: size is " - + std::to_string(sdl_joysticks_.size()) + "; index is " - + std::to_string(index) + "."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Invalid index on RemoveSDLInputDevice: size is " + + std::to_string(sdl_joysticks_.size()) + "; index is " + + std::to_string(index) + "."); } g_base->input->PushRemoveInputDeviceCall(j, true); } diff --git a/src/ballistica/base/app_adapter/app_adapter_vr.cc b/src/ballistica/base/app_adapter/app_adapter_vr.cc index 571177ad..821cc6d8 100644 --- a/src/ballistica/base/app_adapter/app_adapter_vr.cc +++ b/src/ballistica/base/app_adapter/app_adapter_vr.cc @@ -52,8 +52,8 @@ void AppAdapterVR::VRPreDraw() { assert(g_base->app_adapter->InGraphicsContext()); // FIXME - this is internal graphics-server details that the render-server // should handle. - Log(LogName::kBaGraphics, LogLevel::kWarning, - "FIXME: Have GraphicsServer handle VR drawing."); + g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, + "FIXME: Have GraphicsServer handle VR drawing."); // if (FrameDef* frame_def = g_base->graphics_server->GetRenderFrameDef()) { // // Note: this could be part of PreprocessRenderFrameDef but the non-vr // // path needs it to be separate since preprocess doesn't happen @@ -76,8 +76,8 @@ void AppAdapterVR::VRPostDraw() { g_base->graphics_server->FinishRenderFrameDef(vr_render_frame_def_); vr_render_frame_def_ = nullptr; } - Log(LogName::kBaGraphics, LogLevel::kWarning, - "WOULD RUN RENDER UPKEEP CYCLE"); + g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, + "WOULD RUN RENDER UPKEEP CYCLE"); // RunRenderUpkeepCycle(); } diff --git a/src/ballistica/base/assets/assets.cc b/src/ballistica/base/assets/assets.cc index 262feda6..e7cd35dd 100644 --- a/src/ballistica/base/assets/assets.cc +++ b/src/ballistica/base/assets/assets.cc @@ -302,7 +302,7 @@ void Assets::PrintLoadInfo() { snprintf(buffer, sizeof(buffer), " %-50s %10s %10s", "FILE", "PRELOAD_TIME", "LOAD_TIME"); s += buffer; - Log(LogName::kBaAssets, LogLevel::kInfo, s); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, s); millisecs_t total_preload_time = 0; millisecs_t total_load_time = 0; assert(asset_lists_locked_); @@ -315,7 +315,7 @@ void Assets::PrintLoadInfo() { i.second->GetName().c_str(), static_cast_check_fit(preload_time), static_cast_check_fit(load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); num++; } assert(asset_lists_locked_); @@ -328,7 +328,7 @@ void Assets::PrintLoadInfo() { i.second->GetName().c_str(), static_cast_check_fit(preload_time), static_cast_check_fit(load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); num++; } assert(asset_lists_locked_); @@ -341,7 +341,7 @@ void Assets::PrintLoadInfo() { i.second->GetName().c_str(), static_cast_check_fit(preload_time), static_cast_check_fit(load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); num++; } assert(asset_lists_locked_); @@ -354,7 +354,7 @@ void Assets::PrintLoadInfo() { i.second->GetName().c_str(), static_cast_check_fit(preload_time), static_cast_check_fit(load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); num++; } assert(asset_lists_locked_); @@ -367,7 +367,7 @@ void Assets::PrintLoadInfo() { i.second->file_name_full().c_str(), static_cast_check_fit(preload_time), static_cast_check_fit(load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); num++; } snprintf(buffer, sizeof(buffer), @@ -375,7 +375,7 @@ void Assets::PrintLoadInfo() { "(feeding data to OpenGL, etc): %i", static_cast(total_preload_time), static_cast(total_load_time)); - Log(LogName::kBaAssets, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, buffer); } void Assets::MarkAllAssetsForLoad() { @@ -1029,35 +1029,37 @@ void Assets::Prune(int level) { if (kShowPruningInfo) { assert(asset_lists_locked_); if (textures_.size() != old_texture_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "Textures pruned from " + std::to_string(old_texture_count) + " to " - + std::to_string(textures_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "Textures pruned from " + std::to_string(old_texture_count) + + " to " + std::to_string(textures_.size())); } if (text_textures_.size() != old_text_texture_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "TextTextures pruned from " + std::to_string(old_text_texture_count) - + " to " + std::to_string(text_textures_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "TextTextures pruned from " + + std::to_string(old_text_texture_count) + " to " + + std::to_string(text_textures_.size())); } if (qr_textures_.size() != old_qr_texture_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "QrTextures pruned from " + std::to_string(old_qr_texture_count) - + " to " + std::to_string(qr_textures_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "QrTextures pruned from " + + std::to_string(old_qr_texture_count) + " to " + + std::to_string(qr_textures_.size())); } if (meshes_.size() != old_mesh_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "Meshes pruned from " + std::to_string(old_mesh_count) + " to " - + std::to_string(meshes_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "Meshes pruned from " + std::to_string(old_mesh_count) + + " to " + std::to_string(meshes_.size())); } if (collision_meshes_.size() != old_collision_mesh_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "CollisionMeshes pruned from " - + std::to_string(old_collision_mesh_count) + " to " - + std::to_string(collision_meshes_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "CollisionMeshes pruned from " + + std::to_string(old_collision_mesh_count) + " to " + + std::to_string(collision_meshes_.size())); } if (sounds_.size() != old_sound_count) { - Log(LogName::kBaAssets, LogLevel::kInfo, - "Sounds pruned from " + std::to_string(old_sound_count) + " to " - + std::to_string(sounds_.size())); + g_core->Log(LogName::kBaAssets, LogLevel::kInfo, + "Sounds pruned from " + std::to_string(old_sound_count) + + " to " + std::to_string(sounds_.size())); } } } @@ -1164,12 +1166,12 @@ auto Assets::FindAssetFile(FileType type, const std::string& name) // We wanna fail gracefully for some types. if (type == FileType::kSound && name != "blank") { - Log(LogName::kBaAssets, LogLevel::kError, - "Unable to load audio: '" + name + "'; trying fallback..."); + g_core->Log(LogName::kBaAssets, LogLevel::kError, + "Unable to load audio: '" + name + "'; trying fallback..."); return FindAssetFile(type, "blank"); } else if (type == FileType::kTexture && name != "white") { - Log(LogName::kBaAssets, LogLevel::kError, - "Unable to load texture: '" + name + "'; trying fallback..."); + g_core->Log(LogName::kBaAssets, LogLevel::kError, + "Unable to load texture: '" + name + "'; trying fallback..."); return FindAssetFile(type, "white"); } @@ -1228,8 +1230,8 @@ void Assets::AddPackage(const std::string& name, const std::string& path) { assert(g_base->InLogicThread()); if (g_buildconfig.debug_build()) { if (packages_.find(name) != packages_.end()) { - Log(LogName::kBaAssets, LogLevel::kWarning, - "adding duplicate package: '" + name + "'"); + g_core->Log(LogName::kBaAssets, LogLevel::kWarning, + "adding duplicate package: '" + name + "'"); } } packages_[name] = path; @@ -1573,9 +1575,9 @@ auto Assets::CompileResourceString(const std::string& s, const std::string& loc, cJSON* root = cJSON_Parse(s.c_str()); if (root == nullptr) { - Log(LogName::kBaAssets, LogLevel::kError, - "CompileResourceString failed (loc " + loc + "); invalid json: '" + s - + "'"); + g_core->Log(LogName::kBaAssets, LogLevel::kError, + "CompileResourceString failed (loc " + loc + + "); invalid json: '" + s + "'"); *valid = false; return ""; } @@ -1584,9 +1586,9 @@ auto Assets::CompileResourceString(const std::string& s, const std::string& loc, result = DoCompileResourceString(root); *valid = true; } catch (const std::exception& e) { - Log(LogName::kBaAssets, LogLevel::kError, - "CompileResourceString failed (loc " + loc - + "): " + std::string(e.what()) + "; str='" + s + "'"); + g_core->Log(LogName::kBaAssets, LogLevel::kError, + "CompileResourceString failed (loc " + loc + + "): " + std::string(e.what()) + "; str='" + s + "'"); result = ""; *valid = false; } diff --git a/src/ballistica/base/assets/assets_server.cc b/src/ballistica/base/assets/assets_server.cc index 146cdca7..88c03a9b 100644 --- a/src/ballistica/base/assets/assets_server.cc +++ b/src/ballistica/base/assets/assets_server.cc @@ -56,7 +56,8 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) { // We only allow writing one replay at once; make sure that's actually // the case. if (writing_replay_) { - Log(LogName::kBaAssets, LogLevel::kError, + g_core->Log( + LogName::kBaAssets, LogLevel::kError, "AssetsServer got BeginWriteReplayCall while already writing"); WriteReplayMessages(); if (replay_out_file_) { @@ -76,8 +77,8 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) { replay_bytes_written_ = 0; if (!replay_out_file_) { - Log(LogName::kBa, LogLevel::kError, - "unable to open output-stream file: '" + file_path + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "unable to open output-stream file: '" + file_path + "'"); } else { // Write file id and protocol-version. // NOTE: We always write replays in our host protocol version @@ -88,9 +89,9 @@ void AssetsServer::PushBeginWriteReplayCall(uint16_t protocol_version) { || (fwrite(&version, sizeof(version), 1, replay_out_file_) != 1)) { fclose(replay_out_file_); replay_out_file_ = nullptr; - Log(LogName::kBa, LogLevel::kError, - "error writing replay file header: " - + g_core->platform->GetErrnoString()); + g_core->Log(LogName::kBa, LogLevel::kError, + "error writing replay file header: " + + g_core->platform->GetErrnoString()); } replay_bytes_written_ = 5; } @@ -110,7 +111,8 @@ void AssetsServer::PushAddMessageToReplayCall( // Sanity check. if (!writing_replay_) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "AssetsServer got AddMessageToReplayCall while not writing replay"); replays_broken_ = true; return; @@ -121,8 +123,8 @@ void AssetsServer::PushAddMessageToReplayCall( // If we've got too much data built up (lets go with 10 megs for now), // abort. if (replay_message_bytes_ > 10000000) { - Log(LogName::kBa, LogLevel::kError, - "replay output buffer exceeded 10 megs; aborting replay"); + g_core->Log(LogName::kBa, LogLevel::kError, + "replay output buffer exceeded 10 megs; aborting replay"); fclose(replay_out_file_); replay_out_file_ = nullptr; replay_message_bytes_ = 0; @@ -143,8 +145,8 @@ void AssetsServer::PushEndWriteReplayCall() { // Sanity check. if (!writing_replay_) { - Log(LogName::kBa, LogLevel::kError, - "_finishWritingReplay called while not writing"); + g_core->Log(LogName::kBa, LogLevel::kError, + "_finishWritingReplay called while not writing"); replays_broken_ = true; return; } @@ -181,9 +183,9 @@ void AssetsServer::WriteReplayMessages() { if (fwrite(&len8, 1, 1, replay_out_file_) != 1) { fclose(replay_out_file_); replay_out_file_ = nullptr; - Log(LogName::kBaAudio, LogLevel::kError, - "error writing replay file: " - + g_core->platform->GetErrnoString()); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "error writing replay file: " + + g_core->platform->GetErrnoString()); return; } } @@ -194,18 +196,18 @@ void AssetsServer::WriteReplayMessages() { if (fwrite(&len16, 2, 1, replay_out_file_) != 1) { fclose(replay_out_file_); replay_out_file_ = nullptr; - Log(LogName::kBaAudio, LogLevel::kError, - "error writing replay file: " - + g_core->platform->GetErrnoString()); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "error writing replay file: " + + g_core->platform->GetErrnoString()); return; } } else { if (fwrite(&len32, 4, 1, replay_out_file_) != 1) { fclose(replay_out_file_); replay_out_file_ = nullptr; - Log(LogName::kBaAudio, LogLevel::kError, - "error writing replay file: " - + g_core->platform->GetErrnoString()); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "error writing replay file: " + + g_core->platform->GetErrnoString()); return; } } @@ -216,7 +218,8 @@ void AssetsServer::WriteReplayMessages() { if (result != 1) { fclose(replay_out_file_); replay_out_file_ = nullptr; - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log( + LogName::kBaAudio, LogLevel::kError, "error writing replay file: " + g_core->platform->GetErrnoString()); return; } diff --git a/src/ballistica/base/assets/sound_asset.cc b/src/ballistica/base/assets/sound_asset.cc index 2b908420..1032c3fe 100644 --- a/src/ballistica/base/assets/sound_asset.cc +++ b/src/ballistica/base/assets/sound_asset.cc @@ -62,9 +62,9 @@ static auto LoadOgg(const char* file_name, std::vector* buffer, f = g_core->platform->FOpen(file_name, "rb"); if (f == nullptr) { fallback = true; - Log(LogName::kBaAudio, LogLevel::kError, - std::string("Can't open sound file '") + file_name - + "' for reading..."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + std::string("Can't open sound file '") + file_name + + "' for reading..."); // Attempt a fallback standin; if that doesn't work, throw in the towel. file_name = "data/global/audio/blank.ogg"; @@ -84,8 +84,8 @@ static auto LoadOgg(const char* file_name, std::vector* buffer, // Try opening the given file if (ov_open_callbacks(f, &ogg_file, nullptr, 0, callbacks) != 0) { - Log(LogName::kBaAudio, LogLevel::kError, - std::string("Error decoding sound file '") + file_name + "'"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + std::string("Error decoding sound file '") + file_name + "'"); fclose(f); @@ -208,9 +208,9 @@ static void LoadCachedOgg(const char* file_name, std::vector* buffer, // with invalid formats of 0 once. Report and ignore if we see // something like that. if (*format != AL_FORMAT_MONO16 && *format != AL_FORMAT_STEREO16) { - Log(LogName::kBaAudio, LogLevel::kError, - std::string("Ignoring invalid audio cache of ") + file_name - + " with format " + std::to_string(*format)); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + std::string("Ignoring invalid audio cache of ") + file_name + + " with format " + std::to_string(*format)); } else { return; // SUCCESS!!!! } diff --git a/src/ballistica/base/assets/texture_asset.cc b/src/ballistica/base/assets/texture_asset.cc index 9802069f..3107d73e 100644 --- a/src/ballistica/base/assets/texture_asset.cc +++ b/src/ballistica/base/assets/texture_asset.cc @@ -82,7 +82,7 @@ TextureAsset::TextureAsset(const std::string& qr_url) : is_qr_code_(true) { "QR code url byte length %zu exceeds soft-limit of %zu;" " please use shorter urls. (url=%s)", qr_url.size(), soft_limit, qr_url.c_str()); - Log(LogName::kBaAssets, LogLevel::kWarning, buffer); + g_core->Log(LogName::kBaAssets, LogLevel::kWarning, buffer); } file_name_ = qr_url; valid_ = true; diff --git a/src/ballistica/base/audio/al_sys.cc b/src/ballistica/base/audio/al_sys.cc index d1aa4045..d4fb102d 100644 --- a/src/ballistica/base/audio/al_sys.cc +++ b/src/ballistica/base/audio/al_sys.cc @@ -18,15 +18,15 @@ namespace ballistica::base { void _check_al_error(const char* file, int line) { if (g_base->audio_server->paused()) { - Log(LogName::kBaAudio, LogLevel::kError, - Utils::BaseName(file) + ":" + std::to_string(line) - + ": Checking OpenAL error while paused."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + Utils::BaseName(file) + ":" + std::to_string(line) + + ": Checking OpenAL error while paused."); } ALenum al_err = alGetError(); if (al_err != AL_NO_ERROR) { - Log(LogName::kBaAudio, LogLevel::kError, - Utils::BaseName(file) + ":" + std::to_string(line) - + ": OpenAL Error: " + GetALErrorString(al_err) + ";"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + Utils::BaseName(file) + ":" + std::to_string(line) + + ": OpenAL Error: " + GetALErrorString(al_err) + ";"); } } diff --git a/src/ballistica/base/audio/audio.cc b/src/ballistica/base/audio/audio.cc index 7c8f7b4d..6744aeea 100644 --- a/src/ballistica/base/audio/audio.cc +++ b/src/ballistica/base/audio/audio.cc @@ -166,21 +166,21 @@ auto Audio::SafePlaySysSound(SysSoundID sound_id) -> std::optional { return {}; } if (!g_base->InLogicThread()) { - Log(LogName::kBaAudio, LogLevel::kError, - "Audio::SafePlaySysSound called from non-logic thread. id=" - + std::to_string(static_cast(sound_id))); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Audio::SafePlaySysSound called from non-logic thread. id=" + + std::to_string(static_cast(sound_id))); return {}; } if (!g_base->assets->sys_assets_loaded()) { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Audio::SafePlaySysSound called before sys assets loaded. id=" - + std::to_string(static_cast(sound_id))); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Audio::SafePlaySysSound called before sys assets loaded. id=" + + std::to_string(static_cast(sound_id))); return {}; } if (!g_base->assets->IsValidSysSound(sound_id)) { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Audio::SafePlaySysSound called with invalid sound_id. id=" - + std::to_string(static_cast(sound_id))); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Audio::SafePlaySysSound called with invalid sound_id. id=" + + std::to_string(static_cast(sound_id))); return {}; } return PlaySound(g_base->assets->SysSound(sound_id)); diff --git a/src/ballistica/base/audio/audio_server.cc b/src/ballistica/base/audio/audio_server.cc index e07fb02c..39e7f443 100644 --- a/src/ballistica/base/audio/audio_server.cc +++ b/src/ballistica/base/audio/audio_server.cc @@ -179,9 +179,9 @@ static void ALEventCallback_(ALenum eventType, ALuint object, ALuint param, [] { g_base->audio_server->OnDeviceDisconnected(); }); } } else { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Got unexpected OpenAL callback event " - + std::to_string(static_cast(eventType))); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Got unexpected OpenAL callback event " + + std::to_string(static_cast(eventType))); } } @@ -245,7 +245,8 @@ void AudioServer::OnAppStartInThread_() { if (g_core->platform->GetOSVersionString().compare(0, prefix2.size(), prefix2) == 0) { - Log(LogName::kBaAudio, LogLevel::kInfo, + g_core->Log( + LogName::kBaAudio, LogLevel::kInfo, "Xiaomi Android 11 detected; using OpenSL instead of AAudio."); g_core->platform->SetEnv("BA_OBOE_USE_OPENSLES", "1"); } @@ -261,8 +262,8 @@ void AudioServer::OnAppStartInThread_() { ALboolean enumeration = alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT"); if (enumeration == AL_FALSE) { - Log(LogName::kBaAudio, LogLevel::kError, - "OpenAL enumeration extensions missing."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "OpenAL enumeration extensions missing."); } else { const ALCchar* devices = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); @@ -300,7 +301,7 @@ void AudioServer::OnAppStartInThread_() { if (!device) { if (g_buildconfig.ostype_android()) { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log(LogName::kBaAudio, LogLevel::kError, "------------------------" " OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -317,11 +318,11 @@ void AudioServer::OnAppStartInThread_() { // Android special case: if we fail, try again after a few seconds. if (!impl_->alc_context && g_buildconfig.ostype_android()) { - Log(LogName::kBaAudio, LogLevel::kError, - "Failed creating AL context; waiting and trying again."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Failed creating AL context; waiting and trying again."); { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kWarning, + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, "------------------------" " OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -336,7 +337,7 @@ void AudioServer::OnAppStartInThread_() { if (!device) { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log(LogName::kBaAudio, LogLevel::kError, "------------------------" " OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -348,18 +349,19 @@ void AudioServer::OnAppStartInThread_() { impl_->alc_context = alcCreateContext(device, nullptr); if (impl_->alc_context) { // For now want to explicitly know if this works. - Log(LogName::kBaAudio, LogLevel::kWarning, - "Backup AL context creation successful!"); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Backup AL context creation successful!"); } } // Android special case: if we fail, try OpenSL back-end. if (!impl_->alc_context && g_buildconfig.ostype_android()) { - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log( + LogName::kBaAudio, LogLevel::kError, "Failed second time creating AL context; trying OpenSL backend."); { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kWarning, + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, "------------------------" " OPENALSOFT-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -373,7 +375,7 @@ void AudioServer::OnAppStartInThread_() { alGetError(); // Clear any errors. if (!device) { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log(LogName::kBaAudio, LogLevel::kError, "------------------------" " OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -385,8 +387,8 @@ void AudioServer::OnAppStartInThread_() { impl_->alc_context = alcCreateContext(device, nullptr); if (impl_->alc_context) { // For now want to explicitly know if this works. - Log(LogName::kBaAudio, LogLevel::kWarning, - "Backup AL context creation 2 successful!"); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Backup AL context creation 2 successful!"); } } @@ -394,7 +396,7 @@ void AudioServer::OnAppStartInThread_() { if (!impl_->alc_context) { if (g_buildconfig.ostype_android()) { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kError, + g_core->Log(LogName::kBaAudio, LogLevel::kError, "------------------------" " OPENALSOFT-FATAL-ERROR-LOG-BEGIN ----------------------\n" + openalsoft_android_log_ @@ -463,9 +465,9 @@ void AudioServer::OnAppStartInThread_() { sound_source_refs_.push_back(s); sources_.push_back(&(*s)); } else { - Log(LogName::kBaAudio, LogLevel::kError, - "Made " + std::to_string(i) + " sources; (wanted " - + std::to_string(target_source_count) + ")."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Made " + std::to_string(i) + " sources; (wanted " + + std::to_string(target_source_count) + ")."); break; } } @@ -503,23 +505,24 @@ void AudioServer::CompleteShutdown_() { #if BA_ENABLE_AUDIO ALCboolean check = alcMakeContextCurrent(nullptr); if (!check) { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Error on alcMakeContextCurrent at shutdown."); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Error on alcMakeContextCurrent at shutdown."); } auto* device = alcGetContextsDevice(impl_->alc_context); if (!device) { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Unable to get ALCdevice at shutdown."); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Unable to get ALCdevice at shutdown."); } else { alcDestroyContext(impl_->alc_context); ALenum err = alcGetError(device); if (err != ALC_NO_ERROR) { - Log(LogName::kBaAudio, LogLevel::kWarning, "Error on AL shutdown."); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Error on AL shutdown."); } check = alcCloseDevice(device); if (!check) { - Log(LogName::kBaAudio, LogLevel::kWarning, - "Error on alcCloseDevice at shutdown."); + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, + "Error on alcCloseDevice at shutdown."); } } #endif @@ -542,8 +545,8 @@ struct AudioServer::SoundFadeNode_ { void AudioServer::SetSuspended_(bool suspend) { if (!suspended_) { if (!suspend) { - Log(LogName::kBaAudio, LogLevel::kError, - "Got audio unsuspend request when already unsuspended."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Got audio unsuspend request when already unsuspended."); } else { #if BA_OSTYPE_IOS_TVOS // apple recommends this during audio-interruptions.. @@ -565,16 +568,16 @@ void AudioServer::SetSuspended_(bool suspend) { + std::to_string(g_core->GetAppTimeSeconds())); alcDevicePauseSOFT(device); } catch (const std::exception& e) { - Log(LogName::kBaAudio, LogLevel::kError, - "Error in alcDevicePauseSOFT at time " - + std::to_string(g_core->GetAppTimeSeconds()) - + "( playing since " - + std::to_string(last_started_playing_time_) - + "): " + g_core->platform->DemangleCXXSymbol(typeid(e).name()) - + " " + e.what()); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Error in alcDevicePauseSOFT at time " + + std::to_string(g_core->GetAppTimeSeconds()) + + "( playing since " + + std::to_string(last_started_playing_time_) + "): " + + g_core->platform->DemangleCXXSymbol(typeid(e).name()) + + " " + e.what()); } catch (...) { - Log(LogName::kBaAudio, LogLevel::kError, - "Unknown error in alcDevicePauseSOFT"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Unknown error in alcDevicePauseSOFT"); } #endif @@ -583,8 +586,8 @@ void AudioServer::SetSuspended_(bool suspend) { } else { // Unsuspend if requested. if (suspend) { - Log(LogName::kBaAudio, LogLevel::kError, - "Got audio suspend request when already suspended."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Got audio suspend request when already suspended."); } else { #if BA_OSTYPE_IOS_TVOS // Apple recommends this during audio-interruptions. @@ -608,14 +611,14 @@ void AudioServer::SetSuspended_(bool suspend) { + std::to_string(g_core->GetAppTimeSeconds())); alcDeviceResumeSOFT(device); } catch (const std::exception& e) { - Log(LogName::kBaAudio, LogLevel::kError, - "Error in alcDeviceResumeSOFT at time " - + std::to_string(g_core->GetAppTimeSeconds()) + ": " - + g_core->platform->DemangleCXXSymbol(typeid(e).name()) + " " - + e.what()); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Error in alcDeviceResumeSOFT at time " + + std::to_string(g_core->GetAppTimeSeconds()) + ": " + + g_core->platform->DemangleCXXSymbol(typeid(e).name()) + + " " + e.what()); } catch (...) { - Log(LogName::kBaAudio, LogLevel::kError, - "Unknown error in alcDeviceResumeSOFT"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Unknown error in alcDeviceResumeSOFT"); } #endif last_started_playing_time_ = g_core->GetAppTimeSeconds(); @@ -787,10 +790,11 @@ void AudioServer::UpdateAvailableSources_() { // that probably means somebody's grabbing a source but never // resubmitting it. if (t - i->client_source()->last_lock_time() > 10000) { - Log(LogName::kBaAudio, LogLevel::kError, - "Client audio source has been locked for too long; " - "probably leaked. (debug id " - + std::to_string(i->client_source()->lock_debug_id()) + ")"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Client audio source has been locked for too long; " + "probably leaked. (debug id " + + std::to_string(i->client_source()->lock_debug_id()) + + ")"); } continue; } @@ -936,8 +940,8 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) { if (connected == 0 && real_time_seconds - last_reset_attempt_time_ >= retry_interval) { - Log(LogName::kBaAudio, LogLevel::kInfo, - "OpenAL device disconnected; resetting..."); + g_core->Log(LogName::kBaAudio, LogLevel::kInfo, + "OpenAL device disconnected; resetting..."); if (g_buildconfig.ostype_android()) { std::scoped_lock lock(openalsoft_android_log_mutex_); openalsoft_android_log_ += @@ -1006,7 +1010,7 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) { shipped_reconnect_logs_ = true; if (g_buildconfig.ostype_android()) { std::scoped_lock lock(openalsoft_android_log_mutex_); - Log(LogName::kBaAudio, LogLevel::kWarning, + g_core->Log(LogName::kBaAudio, LogLevel::kWarning, "Have been disconnected for a while; dumping OpenAL log.\n" "------------------------" " OPENALSOFT-RECONNECT-LOG-BEGIN ----------------------\n" @@ -1164,9 +1168,9 @@ AudioServer::ThreadSource_::ThreadSource_(AudioServer* audio_server_in, ALenum err = alGetError(); valid_ = (err == AL_NO_ERROR); if (!valid_) { - Log(LogName::kBaAudio, LogLevel::kError, - std::string("AL Error ") + GetALErrorString(err) - + " on source creation."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + std::string("AL Error ") + GetALErrorString(err) + + " on source creation."); } else { // In vr mode we keep the microphone a bit closer to the camera // for realism purposes, so we need stuff louder in general. diff --git a/src/ballistica/base/audio/audio_source.cc b/src/ballistica/base/audio/audio_source.cc index 633e53b8..91894241 100644 --- a/src/ballistica/base/audio/audio_source.cc +++ b/src/ballistica/base/audio/audio_source.cc @@ -42,8 +42,8 @@ void AudioSource::SetPosition(float x, float y, float z) { assert(client_queue_size_ > 0); #if BA_DEBUG_BUILD if (std::isnan(x) || std::isnan(y) || std::isnan(z)) { - Log(LogName::kBaAudio, LogLevel::kError, - "Got nan value in AudioSource::SetPosition."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Got nan value in AudioSource::SetPosition."); } #endif g_base->audio_server->PushSourceSetPositionCall(play_id_, Vector3f(x, y, z)); diff --git a/src/ballistica/base/audio/audio_streamer.cc b/src/ballistica/base/audio/audio_streamer.cc index 71bf2629..56a9061a 100644 --- a/src/ballistica/base/audio/audio_streamer.cc +++ b/src/ballistica/base/audio/audio_streamer.cc @@ -89,9 +89,9 @@ void AudioStreamer::Update() { // A fun anomaly in the linux version; we sometimes get more // "processed" buffers than we have queued. if (queued < processed) { - Log(LogName::kBaAudio, LogLevel::kError, - "Streamer oddness: queued(" + std::to_string(queued) + "); processed(" - + std::to_string(processed) + ")"); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Streamer oddness: queued(" + std::to_string(queued) + + "); processed(" + std::to_string(processed) + ")"); processed = queued; } diff --git a/src/ballistica/base/audio/ogg_stream.cc b/src/ballistica/base/audio/ogg_stream.cc index 14e27146..c25648e8 100644 --- a/src/ballistica/base/audio/ogg_stream.cc +++ b/src/ballistica/base/audio/ogg_stream.cc @@ -93,8 +93,8 @@ void OggStream::DoStream(char* pcm, int* size, unsigned int* rate) { static bool reported_error = false; if (!reported_error) { reported_error = true; - Log(LogName::kBaAudio, LogLevel::kError, - "Error streaming ogg file: '" + file_name() + "'."); + g_core->Log(LogName::kBaAudio, LogLevel::kError, + "Error streaming ogg file: '" + file_name() + "'."); } if (loops()) { ov_pcm_seek(&ogg_file_, 0); diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index daf3259a..cb7983be 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -155,7 +155,8 @@ void BaseFeatureSet::SuccessScreenMessage() { python->objs().Get(BasePython::ObjID::kSuccessMessageCall).Call(); }); } else { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "SuccessScreenMessage called without logic event_loop in place."); } } @@ -166,8 +167,8 @@ void BaseFeatureSet::ErrorScreenMessage() { python->objs().Get(BasePython::ObjID::kErrorMessageCall).Call(); }); } else { - Log(LogName::kBa, LogLevel::kError, - "ErrorScreenMessage called without logic event_loop in place."); + g_core->Log(LogName::kBa, LogLevel::kError, + "ErrorScreenMessage called without logic event_loop in place."); } } @@ -181,7 +182,8 @@ auto BaseFeatureSet::GetV2AccountID() -> std::optional { } return result.ValueAsString(); } else { - Log(LogName::kBa, LogLevel::kError, "GetV2AccountID() py call errored."); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetV2AccountID() py call errored."); return {}; } } @@ -253,7 +255,7 @@ void BaseFeatureSet::StartApp() { char buffer[128]; snprintf(buffer, sizeof(buffer), "StartApp() took too long (%.2lf seconds).", duration); - Log(LogName::kBa, LogLevel::kWarning, buffer); + g_core->Log(LogName::kBa, LogLevel::kWarning, buffer); } } @@ -262,8 +264,8 @@ void BaseFeatureSet::SuspendApp() { assert(g_core->InMainThread()); if (app_suspended_) { - Log(LogName::kBa, LogLevel::kWarning, - "AppAdapter::SuspendApp() called with app already suspended."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "AppAdapter::SuspendApp() called with app already suspended."); return; } @@ -304,7 +306,8 @@ void BaseFeatureSet::SuspendApp() { // running_loop_count = loops.size(); if (running_loops.empty()) { if (g_buildconfig.debug_build()) { - Log(LogName::kBa, LogLevel::kDebug, + g_core->Log( + LogName::kBa, LogLevel::kDebug, "SuspendApp() completed in " + std::to_string(core::CorePlatform::GetCurrentMillisecs() - start_time) @@ -365,7 +368,7 @@ void BaseFeatureSet::SuspendApp() { } msg += ")."; - Log(LogName::kBa, LogLevel::kError, msg); + g_core->Log(LogName::kBa, LogLevel::kError, msg); } void BaseFeatureSet::UnsuspendApp() { @@ -373,7 +376,8 @@ void BaseFeatureSet::UnsuspendApp() { assert(g_core->InMainThread()); if (!app_suspended_) { - Log(LogName::kBa, LogLevel::kWarning, + g_core->Log( + LogName::kBa, LogLevel::kWarning, "AppAdapter::UnsuspendApp() called with app not in suspendedstate."); return; } @@ -391,11 +395,11 @@ void BaseFeatureSet::UnsuspendApp() { g_base->networking->OnAppUnsuspend(); if (g_buildconfig.debug_build()) { - Log(LogName::kBa, LogLevel::kDebug, - "UnsuspendApp() completed in " - + std::to_string(core::CorePlatform::GetCurrentMillisecs() - - start_time) - + "ms."); + g_core->Log(LogName::kBa, LogLevel::kDebug, + "UnsuspendApp() completed in " + + std::to_string(core::CorePlatform::GetCurrentMillisecs() + - start_time) + + "ms."); } } @@ -422,7 +426,7 @@ void BaseFeatureSet::LogVersionInfo_() { snprintf(buffer, sizeof(buffer), "BallisticaKit %s build %d.", kEngineVersion, kEngineBuildNumber); } - Log(LogName::kBaLifecycle, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBaLifecycle, LogLevel::kInfo, buffer); } void BaseFeatureSet::set_app_mode(AppMode* mode) { @@ -431,7 +435,8 @@ void BaseFeatureSet::set_app_mode(AppMode* mode) { // Redundant sets should not happen (make an exception here for empty mode // since that's in place before any app mode is officially set). if (mode == app_mode_ && mode != EmptyAppMode::GetSingleton()) { - Log(LogName::kBa, LogLevel::kWarning, + g_core->Log( + LogName::kBa, LogLevel::kWarning, "set_app_mode called with already-current app-mode; unexpected."); } @@ -559,8 +564,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { if (!have_app_instance_uuid) { // As an emergency fallback simply use a single random number. We // should probably simply disallow this before Python is up. - Log(LogName::kBa, LogLevel::kWarning, - "GetSessionUUID() using rand fallback."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "GetSessionUUID() using rand fallback."); srand(static_cast( core::CorePlatform::GetCurrentMillisecs())); // NOLINT app_instance_uuid = @@ -568,8 +573,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { have_app_instance_uuid = true; } if (app_instance_uuid.size() >= 100) { - Log(LogName::kBa, LogLevel::kWarning, - "session id longer than it should be."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "session id longer than it should be."); } } return app_instance_uuid; @@ -962,9 +967,9 @@ void BaseFeatureSet::SetAppActive(bool active) { // Issue a gentle warning if they are feeding us the same state twice in a // row; might imply faulty logic on an app-adapter or whatnot. if (app_active_set_ && app_active_ == active) { - Log(LogName::kBa, LogLevel::kWarning, - "SetAppActive called with state " + std::to_string(active) - + " twice in a row."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "SetAppActive called with state " + std::to_string(active) + + " twice in a row."); } app_active_set_ = true; app_active_ = active; diff --git a/src/ballistica/base/graphics/gl/program/program_blur_gl.h b/src/ballistica/base/graphics/gl/program/program_blur_gl.h index f7d4f546..86b74586 100644 --- a/src/ballistica/base/graphics/gl/program/program_blur_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_blur_gl.h @@ -86,8 +86,8 @@ class RendererGL::ProgramBlurGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); return s; } @@ -121,7 +121,8 @@ class RendererGL::ProgramBlurGL : public RendererGL::ProgramGL { "(colorTex,vUV8));\n" "}"; if (flags & SHD_DEBUG_PRINT) { - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); } return s; diff --git a/src/ballistica/base/graphics/gl/program/program_gl.h b/src/ballistica/base/graphics/gl/program/program_gl.h index 6e4784a3..4184e5a6 100644 --- a/src/ballistica/base/graphics/gl/program/program_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_gl.h @@ -49,12 +49,12 @@ class RendererGL::ShaderGL : public Object { const char* renderer = (const char*)glGetString(GL_RENDERER); // Let's not crash here. We have a better chance of calling home this // way and theres a chance the game will still be playable. - Log(LogName::kBaGraphics, LogLevel::kError, - std::string("Compile failed for ") + GetTypeName() - + " shader:\n------------SOURCE BEGIN-------------\n" + src_fin - + "\n-----------SOURCE END-------------\n" + GetInfo() - + "\nrenderer: " + renderer + "\nvendor: " + vendor - + "\nversion:" + version); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + std::string("Compile failed for ") + GetTypeName() + + " shader:\n------------SOURCE BEGIN-------------\n" + + src_fin + "\n-----------SOURCE END-------------\n" + + GetInfo() + "\nrenderer: " + renderer + + "\nvendor: " + vendor + "\nversion:" + version); } else { assert(compile_status == GL_TRUE); std::string info = GetInfo(); @@ -65,12 +65,12 @@ class RendererGL::ShaderGL : public Object { const char* version = (const char*)glGetString(GL_VERSION); const char* vendor = (const char*)glGetString(GL_VENDOR); const char* renderer = (const char*)glGetString(GL_RENDERER); - Log(LogName::kBaGraphics, LogLevel::kError, - std::string("WARNING: info returned for ") + GetTypeName() - + " shader:\n------------SOURCE BEGIN-------------\n" + src_fin - + "\n-----------SOURCE END-------------\n" + info - + "\nrenderer: " + renderer + "\nvendor: " + vendor - + "\nversion:" + version); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + std::string("WARNING: info returned for ") + GetTypeName() + + " shader:\n------------SOURCE BEGIN-------------\n" + + src_fin + "\n-----------SOURCE END-------------\n" + + info + "\nrenderer: " + renderer + + "\nvendor: " + vendor + "\nversion:" + version); } } BA_DEBUG_CHECK_GL_ERROR; @@ -166,8 +166,8 @@ class RendererGL::ProgramGL { GLint linkStatus; glGetProgramiv(program_, GL_LINK_STATUS, &linkStatus); if (linkStatus == GL_FALSE) { - Log(LogName::kBaGraphics, LogLevel::kError, - "Link failed for program '" + name_ + "':\n" + GetInfo()); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "Link failed for program '" + name_ + "':\n" + GetInfo()); } else { assert(linkStatus == GL_TRUE); @@ -176,9 +176,9 @@ class RendererGL::ProgramGL { && (strstr(info.c_str(), "error:") || strstr(info.c_str(), "warning:") || strstr(info.c_str(), "Error:") || strstr(info.c_str(), "Warning:"))) { - Log(LogName::kBaGraphics, LogLevel::kError, - "WARNING: program using frag shader '" + name_ - + "' returned info:\n" + info); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "WARNING: program using frag shader '" + name_ + + "' returned info:\n" + info); } } @@ -315,9 +315,10 @@ class RendererGL::ProgramGL { assert(IsBound()); int c = glGetUniformLocation(program_, tex_name); if (c == -1) { - Log(LogName::kBaGraphics, LogLevel::kError, - "ShaderGL: " + name_ + ": Can't set texture unit for texture '" - + tex_name + "'"); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "ShaderGL: " + name_ + + ": Can't set texture unit for texture '" + tex_name + + "'"); BA_DEBUG_CHECK_GL_ERROR; } else { glUniform1i(c, unit); diff --git a/src/ballistica/base/graphics/gl/program/program_object_gl.h b/src/ballistica/base/graphics/gl/program/program_object_gl.h index fe03290c..58e99266 100644 --- a/src/ballistica/base/graphics/gl/program/program_object_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_object_gl.h @@ -235,8 +235,8 @@ class RendererGL::ProgramObjectGL : public RendererGL::ProgramGL { } s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); return s; } @@ -321,7 +321,8 @@ class RendererGL::ProgramObjectGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); return s; } diff --git a/src/ballistica/base/graphics/gl/program/program_post_process_gl.h b/src/ballistica/base/graphics/gl/program/program_post_process_gl.h index c1d6c532..641a1bb6 100644 --- a/src/ballistica/base/graphics/gl/program/program_post_process_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_post_process_gl.h @@ -158,8 +158,8 @@ class RendererGL::ProgramPostProcessGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); return s; } @@ -306,7 +306,8 @@ class RendererGL::ProgramPostProcessGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); return s; } diff --git a/src/ballistica/base/graphics/gl/program/program_shield_gl.h b/src/ballistica/base/graphics/gl/program/program_shield_gl.h index 1d6f3e48..b211c22a 100644 --- a/src/ballistica/base/graphics/gl/program/program_shield_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_shield_gl.h @@ -54,8 +54,8 @@ class RendererGL::ProgramShieldGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); return s; } @@ -114,7 +114,8 @@ class RendererGL::ProgramShieldGL : public RendererGL::ProgramGL { //" " BA_GLSL_FRAGCOLOR " = vec4(vec3(depth),1);\n" if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); return s; } diff --git a/src/ballistica/base/graphics/gl/program/program_simple_gl.h b/src/ballistica/base/graphics/gl/program/program_simple_gl.h index d96a94f0..1960bf4c 100644 --- a/src/ballistica/base/graphics/gl/program/program_simple_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_simple_gl.h @@ -234,7 +234,7 @@ class RendererGL::ProgramSimpleGL : public RendererGL::ProgramGL { "}"; if (flags & SHD_DEBUG_PRINT) { - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); } @@ -383,7 +383,7 @@ class RendererGL::ProgramSimpleGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) { - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); } diff --git a/src/ballistica/base/graphics/gl/program/program_smoke_gl.h b/src/ballistica/base/graphics/gl/program/program_smoke_gl.h index 8020d495..c57f590a 100644 --- a/src/ballistica/base/graphics/gl/program/program_smoke_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_smoke_gl.h @@ -114,8 +114,8 @@ class RendererGL::ProgramSmokeGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); return s; } @@ -160,7 +160,8 @@ class RendererGL::ProgramSmokeGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); return s; } diff --git a/src/ballistica/base/graphics/gl/program/program_sprite_gl.h b/src/ballistica/base/graphics/gl/program/program_sprite_gl.h index 66f5cebb..60e1c62a 100644 --- a/src/ballistica/base/graphics/gl/program/program_sprite_gl.h +++ b/src/ballistica/base/graphics/gl/program/program_sprite_gl.h @@ -122,8 +122,8 @@ class RendererGL::ProgramSpriteGL : public RendererGL::ProgramGL { s += "}"; if (flags & SHD_DEBUG_PRINT) { - Log(LogName::kBaGraphics, LogLevel::kInfo, - "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + "\nVertex code for shader '" + GetName(flags) + "':\n\n" + s); } return s; } @@ -164,7 +164,8 @@ class RendererGL::ProgramSpriteGL : public RendererGL::ProgramGL { } s += "}"; if (flags & SHD_DEBUG_PRINT) { - Log(LogName::kBaGraphics, LogLevel::kInfo, + g_core->Log( + LogName::kBaGraphics, LogLevel::kInfo, "\nFragment code for shader '" + GetName(flags) + "':\n\n" + s); } return s; diff --git a/src/ballistica/base/graphics/gl/renderer_gl.cc b/src/ballistica/base/graphics/gl/renderer_gl.cc index b434723e..b75623ad 100644 --- a/src/ballistica/base/graphics/gl/renderer_gl.cc +++ b/src/ballistica/base/graphics/gl/renderer_gl.cc @@ -90,7 +90,8 @@ void RendererGL::CheckGLError(const char* file, int line) { BA_PRECONDITION_FATAL(vendor); const char* renderer = (const char*)glGetString(GL_RENDERER); BA_PRECONDITION_FATAL(renderer); - Log(LogName::kBaGraphics, LogLevel::kError, + g_core->Log( + LogName::kBaGraphics, LogLevel::kError, "OpenGL Error at " + std::string(file) + " line " + std::to_string(line) + ": " + GLErrorToString(err) + "\nrenderer: " + renderer + "\nvendor: " + vendor + "\nversion: " + version @@ -223,9 +224,10 @@ void RendererGL::CheckGLCapabilities_() { basestr = "OpenGL"; } - Log(LogName::kBaGraphics, LogLevel::kInfo, - std::string("Using ") + basestr + " (vendor: " + vendor - + ", renderer: " + renderer + ", version: " + version_str + ")."); + g_core->Log(LogName::kBaGraphics, LogLevel::kInfo, + std::string("Using ") + basestr + " (vendor: " + vendor + + ", renderer: " + renderer + ", version: " + version_str + + ")."); // Build a vector of extensions. Newer GLs give us extensions as lists // already, but on older ones we may need to break a single string apart @@ -244,8 +246,8 @@ void RendererGL::CheckGLCapabilities_() { extensions.push_back(extension); } } else { - Log(LogName::kBaGraphics, LogLevel::kWarning, - "Falling back on legacy GL_EXTENSIONS parsing."); + g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, + "Falling back on legacy GL_EXTENSIONS parsing."); // Fall back on parsing the single giant string if need be. // (Can probably kill this). auto* ex = reinterpret_cast(glGetString(GL_EXTENSIONS)); @@ -291,8 +293,8 @@ void RendererGL::CheckGLCapabilities_() { c_types.push_back(TextureCompressionType::kETC1); } else { if (g_buildconfig.ostype_android()) { - Log(LogName::kBaGraphics, LogLevel::kError, - "Android device missing ETC1 support."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "Android device missing ETC1 support."); } } @@ -2387,8 +2389,8 @@ void RendererGL::UpdateVignetteTex_(bool force) { if (err != GL_NO_ERROR) { static bool reported = false; if (!reported) { - Log(LogName::kBaGraphics, LogLevel::kError, - "32-bit vignette creation failed; falling back to 16."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "32-bit vignette creation failed; falling back to 16."); reported = true; } const int kVignetteTexWidth = 64; diff --git a/src/ballistica/base/graphics/gl/texture_data_gl.h b/src/ballistica/base/graphics/gl/texture_data_gl.h index ba6ff65d..4f48994b 100644 --- a/src/ballistica/base/graphics/gl/texture_data_gl.h +++ b/src/ballistica/base/graphics/gl/texture_data_gl.h @@ -27,8 +27,8 @@ class RendererGL::TextureDataGL : public TextureAssetRendererData { ~TextureDataGL() override { if (!g_base->app_adapter->InGraphicsContext()) { - Log(LogName::kBaGraphics, LogLevel::kError, - "TextureDataGL dying outside of graphics thread."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "TextureDataGL dying outside of graphics thread."); } else { // If we're currently bound as anything, clear that out (otherwise a // new texture with that same ID won't be bindable). diff --git a/src/ballistica/base/graphics/graphics.cc b/src/ballistica/base/graphics/graphics.cc index 8ffda286..c60d4c8c 100644 --- a/src/ballistica/base/graphics/graphics.cc +++ b/src/ballistica/base/graphics/graphics.cc @@ -204,7 +204,8 @@ auto Graphics::TextureQualityFromAppConfig() -> TextureQualityRequest { } else if (texqualstr == "Low") { texture_quality_requested = TextureQualityRequest::kLow; } else { - Log(LogName::kBaGraphics, LogLevel::kError, + g_core->Log( + LogName::kBaGraphics, LogLevel::kError, "Invalid texture quality: '" + texqualstr + "'; defaulting to low."); texture_quality_requested = TextureQualityRequest::kLow; } @@ -221,8 +222,8 @@ auto Graphics::VSyncFromAppConfig() -> VSyncRequest { } else if (v_sync == "Never") { return VSyncRequest::kNever; } - Log(LogName::kBaGraphics, LogLevel::kError, - "Invalid 'Vertical Sync' value: '" + v_sync + "'"); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "Invalid 'Vertical Sync' value: '" + v_sync + "'"); return VSyncRequest::kNever; } @@ -241,7 +242,8 @@ auto Graphics::GraphicsQualityFromAppConfig() -> GraphicsQualityRequest { } else if (gqualstr == "Low") { graphics_quality_requested = GraphicsQualityRequest::kLow; } else { - Log(LogName::kBaGraphics, LogLevel::kError, + g_core->Log( + LogName::kBaGraphics, LogLevel::kError, "Invalid graphics quality: '" + gqualstr + "'; defaulting to auto."); graphics_quality_requested = GraphicsQualityRequest::kAuto; } @@ -628,8 +630,8 @@ void Graphics::FadeScreen(bool to, millisecs_t time, PyObject* endcall) { // (otherwise, overlapping fades can cause things to get lost) if (fade_end_call_.Exists()) { if (g_buildconfig.debug_build()) { - Log(LogName::kBaGraphics, LogLevel::kWarning, - "2 fades overlapping; running first fade-end-call early."); + g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, + "2 fades overlapping; running first fade-end-call early."); } fade_end_call_->Schedule(); fade_end_call_.Clear(); @@ -1016,7 +1018,8 @@ void Graphics::DrawFades(FrameDef* frame_def) { // TEMP HACK - don't trigger this while inactive. // Need to make overall fade logic smarter. if (faded_time > 15000 && g_base->app_active()) { - Log(LogName::kBaGraphics, LogLevel::kError, "FORCE-ENDING STUCK FADE"); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "FORCE-ENDING STUCK FADE"); fade_out_ = false; fade_ = 1.0f; fade_time_ = 1000; @@ -1673,7 +1676,8 @@ auto Graphics::ReflectionTypeFromString(const std::string& s) void Graphics::LanguageChanged() { assert(g_base && g_base->InLogicThread()); if (building_frame_def_) { - Log(LogName::kBa, LogLevel::kWarning, + g_core->Log( + LogName::kBa, LogLevel::kWarning, "Graphics::LanguageChanged() called during draw; should not happen."); } screenmessages->ClearScreenMessageTranslations(); @@ -1694,9 +1698,9 @@ auto Graphics::GraphicsQualityFromRequest(GraphicsQualityRequest request, case GraphicsQualityRequest::kAuto: return auto_val; default: - Log(LogName::kBa, LogLevel::kError, - "Unhandled GraphicsQualityRequest value: " - + std::to_string(static_cast(request))); + g_core->Log(LogName::kBa, LogLevel::kError, + "Unhandled GraphicsQualityRequest value: " + + std::to_string(static_cast(request))); return GraphicsQuality::kLow; } } @@ -1714,9 +1718,9 @@ auto Graphics::TextureQualityFromRequest(TextureQualityRequest request, case TextureQualityRequest::kAuto: return auto_val; default: - Log(LogName::kBaGraphics, LogLevel::kError, - "Unhandled TextureQualityRequest value: " - + std::to_string(static_cast(request))); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "Unhandled TextureQualityRequest value: " + + std::to_string(static_cast(request))); return TextureQuality::kLow; } } diff --git a/src/ballistica/base/graphics/graphics_server.cc b/src/ballistica/base/graphics/graphics_server.cc index 161dff8d..ce203e4a 100644 --- a/src/ballistica/base/graphics/graphics_server.cc +++ b/src/ballistica/base/graphics/graphics_server.cc @@ -178,9 +178,9 @@ auto GraphicsServer::WaitForRenderFrameDef_() -> FrameDef* { millisecs_t t = g_core->GetAppTimeMillisecs() - start_time; if (t >= 1000) { if (g_buildconfig.debug_build()) { - Log(LogName::kBaGraphics, LogLevel::kWarning, - "GraphicsServer: timed out at " + std::to_string(t) - + "ms waiting for logic thread to send us a FrameDef."); + g_core->Log(LogName::kBaGraphics, LogLevel::kWarning, + "GraphicsServer: timed out at " + std::to_string(t) + + "ms waiting for logic thread to send us a FrameDef."); } break; // Fail. } @@ -266,8 +266,8 @@ void GraphicsServer::ReloadLostRenderer() { assert(g_base->app_adapter->InGraphicsContext()); if (!renderer_) { - Log(LogName::kBaGraphics, LogLevel::kError, - "No renderer on GraphicsServer::ReloadLostRenderer."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "No renderer on GraphicsServer::ReloadLostRenderer."); return; } @@ -324,12 +324,13 @@ void GraphicsServer::set_renderer(Renderer* renderer) { void GraphicsServer::LoadRenderer() { assert(g_base->app_adapter->InGraphicsContext()); if (!renderer_) { - Log(LogName::kBaGraphics, LogLevel::kError, - "LoadRenderer() called with no renderer present."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "LoadRenderer() called with no renderer present."); return; } if (renderer_loaded_) { - Log(LogName::kBaGraphics, LogLevel::kError, + g_core->Log( + LogName::kBaGraphics, LogLevel::kError, "LoadRenderer() called with an already-loaded renderer present."); return; } @@ -371,12 +372,13 @@ void GraphicsServer::LoadRenderer() { void GraphicsServer::UnloadRenderer() { assert(g_base->app_adapter->InGraphicsContext()); if (!renderer_) { - Log(LogName::kBaGraphics, LogLevel::kError, - "UnloadRenderer() called with no renderer present."); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "UnloadRenderer() called with no renderer present."); return; } if (!renderer_loaded_) { - Log(LogName::kBaGraphics, LogLevel::kError, + g_core->Log( + LogName::kBaGraphics, LogLevel::kError, "UnloadRenderer() called with an already unloaded renderer present."); return; } @@ -535,7 +537,7 @@ void GraphicsServer::PushRemoveRenderHoldCall() { assert(render_hold_); render_hold_--; if (render_hold_ < 0) { - Log(LogName::kBaGraphics, LogLevel::kError, "RenderHold < 0"); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, "RenderHold < 0"); render_hold_ = 0; } }); diff --git a/src/ballistica/base/graphics/mesh/mesh_data.h b/src/ballistica/base/graphics/mesh/mesh_data.h index 02eb7c50..6e0637be 100644 --- a/src/ballistica/base/graphics/mesh/mesh_data.h +++ b/src/ballistica/base/graphics/mesh/mesh_data.h @@ -17,8 +17,8 @@ class MeshData { : type_(type), draw_type_(draw_type) {} virtual ~MeshData() { if (renderer_data_) { - Log(LogName::kBaGraphics, LogLevel::kError, - "MeshData going down with rendererData intact!"); + g_core->Log(LogName::kBaGraphics, LogLevel::kError, + "MeshData going down with rendererData intact!"); } } std::list::iterator iterator_; diff --git a/src/ballistica/base/input/device/joystick_input.cc b/src/ballistica/base/input/device/joystick_input.cc index 88fd1e0d..09e8b6c5 100644 --- a/src/ballistica/base/input/device/joystick_input.cc +++ b/src/ballistica/base/input/device/joystick_input.cc @@ -289,7 +289,8 @@ auto JoystickInput::GetButtonName(int index) -> std::string { JoystickInput::~JoystickInput() { if (!g_base->InLogicThread()) { - Log(LogName::kBaInput, LogLevel::kError, "Joystick dying in wrong thread."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Joystick dying in wrong thread."); } // Kill our child if need be. @@ -311,8 +312,8 @@ JoystickInput::~JoystickInput() { [joystick] { SDL_JoystickClose(joystick); }); sdl_joystick_ = nullptr; #else - Log(LogName::kBaInput, LogLevel::kError, - "sdl_joystick_ set in non-sdl-joystick build destructor."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "sdl_joystick_ set in non-sdl-joystick build destructor."); #endif // BA_ENABLE_SDL_JOYSTICKS } } @@ -1231,8 +1232,8 @@ void JoystickInput::UpdateMapping() { auto* cl{g_base->HaveClassic() ? g_base->classic() : nullptr}; if (!cl) { - Log(LogName::kBaInput, LogLevel::kWarning, - "Classic not present; can't config joystick mapping."); + g_core->Log(LogName::kBaInput, LogLevel::kWarning, + "Classic not present; can't config joystick mapping."); } // If we're a child, use our parent's id to search for config values and just diff --git a/src/ballistica/base/input/device/touch_input.cc b/src/ballistica/base/input/device/touch_input.cc index dc236b9d..b514bb15 100644 --- a/src/ballistica/base/input/device/touch_input.cc +++ b/src/ballistica/base/input/device/touch_input.cc @@ -852,8 +852,8 @@ void TouchInput::UpdateMapping() { } else if (touch_movement_type == "joystick") { movement_control_type_ = TouchInput::MovementControlType::kJoystick; } else { - Log(LogName::kBaInput, LogLevel::kError, - "Invalid touch-movement-type: " + touch_movement_type); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Invalid touch-movement-type: " + touch_movement_type); movement_control_type_ = TouchInput::MovementControlType::kSwipe; } std::string touch_action_type = @@ -863,8 +863,8 @@ void TouchInput::UpdateMapping() { } else if (touch_action_type == "buttons") { action_control_type_ = TouchInput::ActionControlType::kButtons; } else { - Log(LogName::kBaInput, LogLevel::kError, - "Invalid touch-action-type: " + touch_action_type); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Invalid touch-action-type: " + touch_action_type); action_control_type_ = TouchInput::ActionControlType::kSwipe; } diff --git a/src/ballistica/base/input/input.cc b/src/ballistica/base/input/input.cc index 72e532ed..3dfe6a38 100644 --- a/src/ballistica/base/input/input.cc +++ b/src/ballistica/base/input/input.cc @@ -34,8 +34,8 @@ void Input::PushCreateKeyboardInputDevices() { void Input::CreateKeyboardInputDevices_() { assert(g_base->InLogicThread()); if (keyboard_input_ != nullptr || keyboard_input_2_ != nullptr) { - Log(LogName::kBaInput, LogLevel::kError, - "CreateKeyboardInputDevices called with existing kbs."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "CreateKeyboardInputDevices called with existing kbs."); return; } keyboard_input_ = Object::NewDeferred(nullptr); @@ -53,8 +53,8 @@ void Input::PushDestroyKeyboardInputDevices() { void Input::DestroyKeyboardInputDevices_() { assert(g_base->InLogicThread()); if (keyboard_input_ == nullptr || keyboard_input_2_ == nullptr) { - Log(LogName::kBaInput, LogLevel::kError, - "DestroyKeyboardInputDevices called with null kb(s)."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "DestroyKeyboardInputDevices called with null kb(s)."); return; } RemoveInputDevice(keyboard_input_, false); @@ -558,8 +558,8 @@ void Input::StepDisplayTime() { // If input has been locked an excessively long amount of time, unlock it. if (input_lock_count_temp_) { if (real_time - last_input_temp_lock_time_ > 10000) { - Log(LogName::kBaInput, LogLevel::kError, - "Input has been temp-locked for 10 seconds; unlocking."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Input has been temp-locked for 10 seconds; unlocking."); input_lock_count_temp_ = 0; PrintLockLabels_(); input_lock_temp_labels_.clear(); @@ -664,10 +664,10 @@ void Input::UnlockAllInput(bool permanent, const std::string& label) { input_lock_count_temp_--; input_unlock_temp_labels_.push_back(label); if (input_lock_count_temp_ < 0) { - Log(LogName::kBaInput, LogLevel::kWarning, - "temp input unlock at time " - + std::to_string(g_core->GetAppTimeMillisecs()) - + " with no active lock: '" + label + "'"); + g_core->Log(LogName::kBaInput, LogLevel::kWarning, + "temp input unlock at time " + + std::to_string(g_core->GetAppTimeMillisecs()) + + " with no active lock: '" + label + "'"); // This is to be expected since we can reset this to 0. input_lock_count_temp_ = 0; } @@ -719,7 +719,7 @@ void Input::PrintLockLabels_() { s += "\n " + std::to_string(num++) + ": " + recent_input_locks_unlock; } - Log(LogName::kBaInput, LogLevel::kError, s); + g_core->Log(LogName::kBaInput, LogLevel::kError, s); } void Input::PushTextInputEvent(const std::string& text) { @@ -757,8 +757,8 @@ void Input::PushTextInputEvent(const std::string& text) { // platforms) but make a stink if they sent us something that we can't // at least translate to unicode. if (!Utils::IsValidUTF8(text)) { - Log(LogName::kBaInput, LogLevel::kWarning, - "PushTextInputEvent passed invalid utf-8 text."); + g_core->Log(LogName::kBaInput, LogLevel::kWarning, + "PushTextInputEvent passed invalid utf-8 text."); return; } @@ -845,8 +845,8 @@ void Input::CaptureKeyboardInput(HandleKeyPressCall* press_call, HandleKeyReleaseCall* release_call) { assert(g_base->InLogicThread()); if (keyboard_input_capture_press_ || keyboard_input_capture_release_) { - Log(LogName::kBaInput, LogLevel::kError, - "Setting key capture redundantly."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Setting key capture redundantly."); } keyboard_input_capture_press_ = press_call; keyboard_input_capture_release_ = release_call; @@ -861,8 +861,8 @@ void Input::ReleaseKeyboardInput() { void Input::CaptureJoystickInput(HandleJoystickEventCall* call) { assert(g_base->InLogicThread()); if (joystick_input_capture_) { - Log(LogName::kBaInput, LogLevel::kError, - "Setting joystick capture redundantly."); + g_core->Log(LogName::kBaInput, LogLevel::kError, + "Setting joystick capture redundantly."); } joystick_input_capture_ = call; } @@ -1570,7 +1570,7 @@ void Input::LsInputDevices() { ++index; } - Log(LogName::kBaInput, LogLevel::kInfo, out); + g_core->Log(LogName::kBaInput, LogLevel::kInfo, out); } auto Input::ShouldAllowInputInAttractMode_(InputDevice* device) const -> bool { diff --git a/src/ballistica/base/logic/logic.cc b/src/ballistica/base/logic/logic.cc index a4eaf1c5..861e90e4 100644 --- a/src/ballistica/base/logic/logic.cc +++ b/src/ballistica/base/logic/logic.cc @@ -6,6 +6,7 @@ #include #include +#include #include "ballistica/base/app_adapter/app_adapter.h" #include "ballistica/base/app_mode/app_mode.h" @@ -24,13 +25,7 @@ namespace ballistica::base { -Logic::Logic() : display_timers_(new TimerList()) { - // Enable display-time debug logs via env var. - auto val = g_core->platform->GetEnv("BA_DEBUG_LOG_DISPLAY_TIME"); - if (val && *val == "1") { - debug_log_display_time_ = true; - } -} +Logic::Logic() : display_timers_(new TimerList()) {} void Logic::OnMainThreadStartApp() { // Spin up our logic thread and sit and wait for it to init. @@ -383,8 +378,9 @@ void Logic::OnAppModeChanged() { // Kick our headless stepping into high gear; this will snap us out of any // long sleep we're currently in the middle of. if (g_core->HeadlessMode()) { - if (debug_log_display_time_) { - Log(LogName::kBa, LogLevel::kDebug, + if (g_core->LogLevelEnabled(LogName::kBaDisplayTime, LogLevel::kDebug)) { + g_core->Log( + LogName::kBaDisplayTime, LogLevel::kDebug, "Resetting headless display step timer due to app-mode change."); } assert(headless_display_time_step_timer_); @@ -415,12 +411,12 @@ void Logic::UpdateDisplayTimeForHeadlessMode_() { display_time_increment_ = static_cast(display_time_increment_microsecs_) / 1000000.0; - if (debug_log_display_time_) { + g_core->Log(LogName::kBaDisplayTime, LogLevel::kDebug, [app_time_microsecs] { char buffer[256]; snprintf(buffer, sizeof(buffer), "stepping display-time at app-time %.4f", static_cast(app_time_microsecs) / 1000000.0); - Log(LogName::kBa, LogLevel::kDebug, buffer); - } + return std::string(buffer); + }); } void Logic::PostUpdateDisplayTimeForHeadlessMode_() { @@ -433,16 +429,18 @@ void Logic::PostUpdateDisplayTimeForHeadlessMode_() { kHeadlessMaxDisplayTimeStep), kHeadlessMinDisplayTimeStep); - if (debug_log_display_time_) { - auto sleepsecs = - static_cast(headless_display_step_microsecs) / 1000000.0; - auto apptimesecs = g_core->GetAppTimeSeconds(); - char buffer[256]; - snprintf(buffer, sizeof(buffer), - "will try to sleep for %.4f at app-time %.4f (until %.4f)", - sleepsecs, apptimesecs, apptimesecs + sleepsecs); - Log(LogName::kBa, LogLevel::kDebug, buffer); - } + g_core->Log( + LogName::kBaDisplayTime, LogLevel::kDebug, + [headless_display_step_microsecs] { + auto sleepsecs = + static_cast(headless_display_step_microsecs) / 1000000.0; + auto apptimesecs = g_core->GetAppTimeSeconds(); + char buffer[256]; + snprintf(buffer, sizeof(buffer), + "will try to sleep for %.4f at app-time %.4f (until %.4f)", + sleepsecs, apptimesecs, apptimesecs + sleepsecs); + return std::string(buffer); + }); auto sleep_microsecs = headless_display_step_microsecs; headless_display_time_step_timer_->SetLength(sleep_microsecs); @@ -543,24 +541,28 @@ void Logic::UpdateDisplayTimeForFrameDraw_() { if (trailing_dist > trail_buffer) { auto offs = (trailing_dist - trail_buffer) * (trailing_diff > 0.0 ? 1.0 : -1.0); - if (debug_log_display_time_) { - char buffer[256]; - snprintf(buffer, sizeof(buffer), - "trailing_dist %.6f > trail_buffer %.6f; will offset %.6f).", - trailing_dist, trail_buffer, offs); - Log(LogName::kBa, LogLevel::kDebug, buffer); - } + g_core->Log( + LogName::kBaDisplayTime, LogLevel::kDebug, + [trailing_dist, trail_buffer, offs] { + char buffer[256]; + snprintf( + buffer, sizeof(buffer), + "trailing_dist %.6f > trail_buffer %.6f; will offset %.6f).", + trailing_dist, trail_buffer, offs); + return std::string(buffer); + }); display_time_increment_ = display_time_increment_ + offs; } - if (debug_log_display_time_) { - char buffer[256]; - snprintf(buffer, sizeof(buffer), - "final %.5f current(%s) %.5f sample %.5f chaos %.5f", - display_time_increment_, use_avg ? "avg" : "sample", used, - this_increment, chaos); - Log(LogName::kBa, LogLevel::kDebug, buffer); - } + g_core->Log(LogName::kBaDisplayTime, LogLevel::kDebug, + [this, use_avg, this_increment, chaos, used] { + char buffer[256]; + snprintf(buffer, sizeof(buffer), + "final %.5f current(%s) %.5f sample %.5f chaos %.5f", + display_time_increment_, use_avg ? "avg" : "sample", + used, this_increment, chaos); + return std::string(buffer); + }); } // Lastly, apply our updated increment value to our time. @@ -660,8 +662,8 @@ void Logic::SetAppTimerLength(int timer_id, microsecs_t length) { if (t) { t->SetLength(length); } else { - Log(LogName::kBa, LogLevel::kError, - "Logic::SetAppTimerLength() called on nonexistent timer."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Logic::SetAppTimerLength() called on nonexistent timer."); } } @@ -687,8 +689,8 @@ void Logic::SetDisplayTimerLength(int timer_id, microsecs_t length) { if (t) { t->SetLength(length); } else { - Log(LogName::kBa, LogLevel::kError, - "Logic::SetDisplayTimerLength() called on nonexistent timer."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Logic::SetDisplayTimerLength() called on nonexistent timer."); } } diff --git a/src/ballistica/base/logic/logic.h b/src/ballistica/base/logic/logic.h index d74e7de4..34abe7d0 100644 --- a/src/ballistica/base/logic/logic.h +++ b/src/ballistica/base/logic/logic.h @@ -146,7 +146,6 @@ class Logic { bool app_active_{true}; bool app_bootstrapping_complete_{}; bool have_pending_loads_{}; - bool debug_log_display_time_{}; bool applied_app_config_{}; bool shutting_down_{}; bool shutdown_completed_{}; diff --git a/src/ballistica/base/networking/network_reader.cc b/src/ballistica/base/networking/network_reader.cc index c77ac749..9892f3b0 100644 --- a/src/ballistica/base/networking/network_reader.cc +++ b/src/ballistica/base/networking/network_reader.cc @@ -61,9 +61,9 @@ void NetworkReader::OnAppUnsuspend() { void NetworkReader::PokeSelf_() { int sd = socket(AF_INET, SOCK_DGRAM, 0); if (sd < 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Unable to create sleep ping socket; errno " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Unable to create sleep ping socket; errno " + + g_core->platform->GetSocketErrorString()); } else { struct sockaddr_in serv_addr{}; memset(&serv_addr, 0, sizeof(serv_addr)); @@ -72,9 +72,9 @@ void NetworkReader::PokeSelf_() { serv_addr.sin_port = 0; // any int bresult = ::bind(sd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); if (bresult == 1) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Unable to bind sleep socket: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Unable to bind sleep socket: " + + g_core->platform->GetSocketErrorString()); } else { struct sockaddr_in t_addr{}; memset(&t_addr, 0, sizeof(t_addr)); @@ -85,9 +85,9 @@ void NetworkReader::PokeSelf_() { ssize_t sresult = sendto(sd, b, 1, 0, (struct sockaddr*)(&t_addr), sizeof(t_addr)); if (sresult == -1) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error on sleep self-sendto: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error on sleep self-sendto: " + + g_core->platform->GetSocketErrorString()); } } g_core->platform->CloseSocket(sd); @@ -118,7 +118,8 @@ void NetworkReader::DoPoll_(bool* can_read_4, bool* can_read_6) { // Aint no thang. } else { // Let's complain for anything else though. - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Error on select: " + g_core->platform->GetSocketErrorString()); } } else { @@ -171,7 +172,8 @@ void NetworkReader::DoSelect_(bool* can_read_4, bool* can_read_6) { // Aint no thang. } else { // Let's complain for anything else though. - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Error on select: " + g_core->platform->GetSocketErrorString()); } } else { @@ -239,9 +241,9 @@ auto NetworkReader::RunThread_() -> int { recvfrom(sd, buffer, sizeof(buffer), 0, reinterpret_cast(&from), &from_size); if (rresult == 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "NetworkReader Recv got length 0; this shouldn't " - "happen"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "NetworkReader Recv got length 0; this shouldn't " + "happen"); } else if (rresult == -1) { // This needs to be locked during any sd changes/writes. std::scoped_lock lock(sd_mutex_); @@ -417,9 +419,9 @@ void NetworkReader::OpenSockets_() { sd4_ = socket(AF_INET, SOCK_DGRAM, 0); if (sd4_ < 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Unable to open host socket; errno " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Unable to open host socket; errno " + + g_core->platform->GetSocketErrorString()); } else { g_core->platform->SetSocketNonBlocking(sd4_); @@ -470,9 +472,9 @@ void NetworkReader::OpenSockets_() { // available everywhere (win XP, etc) so let's do this for now. sd6_ = socket(AF_INET6, SOCK_DGRAM, 0); if (sd6_ < 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Unable to open ipv6 socket: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Unable to open ipv6 socket: " + + g_core->platform->GetSocketErrorString()); } else { // Since we're explicitly creating both a v4 and v6 socket, tell the v6 // to *not* do both itself (not sure if this is necessary; on mac it @@ -481,8 +483,8 @@ void NetworkReader::OpenSockets_() { if (setsockopt(sd6_, IPPROTO_IPV6, IPV6_V6ONLY, reinterpret_cast(&on), sizeof(on)) == -1) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error setting socket as ipv6-only"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error setting socket as ipv6-only"); } g_core->platform->SetSocketNonBlocking(sd6_); @@ -529,9 +531,10 @@ void NetworkReader::OpenSockets_() { + std::to_string(initial_requested_port) + "; some network functionality may fail.", {1, 0.5f, 0}); - Log(LogName::kBaNetworking, LogLevel::kWarning, - "Unable to bind udp port " + std::to_string(initial_requested_port) - + "; some network functionality may fail."); + g_core->Log(LogName::kBaNetworking, LogLevel::kWarning, + "Unable to bind udp port " + + std::to_string(initial_requested_port) + + "; some network functionality may fail."); } } diff --git a/src/ballistica/base/platform/apple/base_platform_apple.cc b/src/ballistica/base/platform/apple/base_platform_apple.cc index f9e80c5e..1b7207f2 100644 --- a/src/ballistica/base/platform/apple/base_platform_apple.cc +++ b/src/ballistica/base/platform/apple/base_platform_apple.cc @@ -116,8 +116,8 @@ void BasePlatformApple::LoginAdapterGetSignInToken( if (login_type == "game_center") { BallisticaKit::GameCenterContext::getSignInToken(attempt_id); } else { - Log(LogName::kBa, LogLevel::kError, - "Got unexpected get-sign-in-token login-type: " + login_type); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got unexpected get-sign-in-token login-type: " + login_type); } #else BasePlatform::LoginAdapterGetSignInToken(login_type, attempt_id); @@ -130,7 +130,8 @@ void BasePlatformApple::LoginAdapterBackEndActiveChange( if (login_type == "game_center") { BallisticaKit::GameCenterContext::backEndActiveChange(active); } else { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Got unexpected back-end-active-change login-type: " + login_type); } #else diff --git a/src/ballistica/base/platform/base_platform.cc b/src/ballistica/base/platform/base_platform.cc index ca581171..7711fc3b 100644 --- a/src/ballistica/base/platform/base_platform.cc +++ b/src/ballistica/base/platform/base_platform.cc @@ -104,12 +104,13 @@ void BasePlatform::DoPurchase(const std::string& item) { } void BasePlatform::RestorePurchases() { - Log(LogName::kBa, LogLevel::kError, "RestorePurchases() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "RestorePurchases() unimplemented"); } void BasePlatform::PurchaseAck(const std::string& purchase, const std::string& order_id) { - Log(LogName::kBa, LogLevel::kError, "PurchaseAck() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, "PurchaseAck() unimplemented"); } void BasePlatform::OpenURL(const std::string& url) { @@ -134,7 +135,8 @@ void BasePlatform::OverlayWebBrowserOpenURL(const std::string& url) { std::scoped_lock lock(web_overlay_mutex_); if (web_overlay_open_) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "OverlayWebBrowserOnClose called with already existing overlay."); return; } @@ -155,8 +157,8 @@ auto BasePlatform::OverlayWebBrowserIsOpen() -> bool { void BasePlatform::OverlayWebBrowserOnClose() { std::scoped_lock lock(web_overlay_mutex_); if (!web_overlay_open_) { - Log(LogName::kBa, LogLevel::kError, - "OverlayWebBrowserOnClose called with no known overlay."); + g_core->Log(LogName::kBa, LogLevel::kError, + "OverlayWebBrowserOnClose called with no known overlay."); } web_overlay_open_ = false; } @@ -174,13 +176,14 @@ void BasePlatform::OverlayWebBrowserClose() { } void BasePlatform::DoOverlayWebBrowserOpenURL(const std::string& url) { - Log(LogName::kBa, LogLevel::kError, - "DoOpenURLInOverlayBrowser unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "DoOpenURLInOverlayBrowser unimplemented"); } void BasePlatform::DoOverlayWebBrowserClose() { // As a default, use Python's webbrowser module functionality. - Log(LogName::kBa, LogLevel::kError, "DoOverlayWebBrowserClose unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "DoOverlayWebBrowserClose unimplemented"); } #if !BA_OSTYPE_WINDOWS @@ -189,7 +192,8 @@ static void HandleSIGINT(int s) { g_base->logic->event_loop()->PushCall( [] { g_base->logic->HandleInterruptSignal(); }); } else { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "SigInt handler called before g_base->logic->event_loop exists."); } } @@ -198,7 +202,8 @@ static void HandleSIGTERM(int s) { g_base->logic->event_loop()->PushCall( [] { g_base->logic->HandleTerminateSignal(); }); } else { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "SigInt handler called before g_base->logic->event_loop exists."); } } @@ -277,18 +282,20 @@ void BasePlatform::StringEditorCancel() { void BasePlatform::DoInvokeStringEditor(const std::string& title, const std::string& value, std::optional max_chars) { - Log(LogName::kBa, LogLevel::kError, - "FIXME: DoInvokeStringEditor() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "FIXME: DoInvokeStringEditor() unimplemented"); } auto BasePlatform::SupportsOpenDirExternally() -> bool { return false; } void BasePlatform::OpenDirExternally(const std::string& path) { - Log(LogName::kBa, LogLevel::kError, "OpenDirExternally() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "OpenDirExternally() unimplemented"); } void BasePlatform::OpenFileExternally(const std::string& path) { - Log(LogName::kBa, LogLevel::kError, "OpenFileExternally() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "OpenFileExternally() unimplemented"); } auto BasePlatform::SafeStdinFGetS(char* s, int n, FILE* iop) -> char* { diff --git a/src/ballistica/base/platform/linux/base_platform_linux.cc b/src/ballistica/base/platform/linux/base_platform_linux.cc index 50b8386e..937757d0 100644 --- a/src/ballistica/base/platform/linux/base_platform_linux.cc +++ b/src/ballistica/base/platform/linux/base_platform_linux.cc @@ -23,9 +23,9 @@ void BasePlatformLinux::OpenDirExternally(const std::string& path) { std::string cmd = std::string("xdg-open \"") + path + "\""; int result = system(cmd.c_str()); if (result != 0) { - Log(LogName::kBa, LogLevel::kError, - "Got return value " + std::to_string(result) + " on xdg-open cmd '" - + cmd + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got return value " + std::to_string(result) + + " on xdg-open cmd '" + cmd + "'"); } } @@ -33,9 +33,9 @@ void BasePlatformLinux::OpenFileExternally(const std::string& path) { std::string cmd = std::string("xdg-open \"") + path + "\""; int result = system(cmd.c_str()); if (result != 0) { - Log(LogName::kBa, LogLevel::kError, - "Got return value " + std::to_string(result) + " on xdg-open cmd '" - + cmd + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got return value " + std::to_string(result) + + " on xdg-open cmd '" + cmd + "'"); } } diff --git a/src/ballistica/base/platform/windows/base_platform_windows.cc b/src/ballistica/base/platform/windows/base_platform_windows.cc index c72012e1..ac61a493 100644 --- a/src/ballistica/base/platform/windows/base_platform_windows.cc +++ b/src/ballistica/base/platform/windows/base_platform_windows.cc @@ -36,8 +36,8 @@ void BasePlatformWindows::DoOpenURL(const std::string& url) { // This should return > 32 on success. if (r <= 32) { - Log(LogName::kBa, LogLevel::kError, - "Error " + std::to_string(r) + " opening URL '" + url + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error " + std::to_string(r) + " opening URL '" + url + "'"); } } } @@ -49,8 +49,8 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { g_base->logic->event_loop()->PushCall( [] { g_base->logic->HandleInterruptSignal(); }); } else { - Log(LogName::kBa, LogLevel::kError, - "SigInt handler called before g_logic exists."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SigInt handler called before g_logic exists."); } return TRUE; @@ -62,7 +62,8 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) { void BasePlatformWindows::SetupInterruptHandling() { // Set up Ctrl-C handling. if (!SetConsoleCtrlHandler(CtrlHandler, TRUE)) { - Log(LogName::kBa, LogLevel::kError, "Error on SetConsoleCtrlHandler()"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error on SetConsoleCtrlHandler()"); } } @@ -74,9 +75,9 @@ void BasePlatformWindows::OpenDirExternally(const std::string& path) { core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr, SW_SHOWNORMAL)); if (r <= 32) { - Log(LogName::kBa, LogLevel::kError, - "Error " + std::to_string(r) + " on open_dir_externally for '" + path - + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error " + std::to_string(r) + " on open_dir_externally for '" + + path + "'"); } } @@ -86,9 +87,9 @@ void BasePlatformWindows::OpenFileExternally(const std::string& path) { core::CorePlatformWindows::UTF8Decode(path).c_str(), nullptr, SW_SHOWNORMAL)); if (r <= 32) { - Log(LogName::kBa, LogLevel::kError, - "Error " + std::to_string(r) + " on open_file_externally for '" + path - + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error " + std::to_string(r) + " on open_file_externally for '" + + path + "'"); } } diff --git a/src/ballistica/base/python/base_python.cc b/src/ballistica/base/python/base_python.cc index edaf6297..9f90a3bb 100644 --- a/src/ballistica/base/python/base_python.cc +++ b/src/ballistica/base/python/base_python.cc @@ -341,7 +341,8 @@ auto BasePython::GetRawConfigValue(const char* name, float default_value) try { return Python::GetPyFloat(value); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "expected a float for config value '" + std::string(name) + "'"); return default_value; } @@ -363,7 +364,8 @@ auto BasePython::GetRawConfigValue(const char* name, } return Python::GetPyFloat(value); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "expected a float for config value '" + std::string(name) + "'"); return default_value; } @@ -380,7 +382,8 @@ auto BasePython::GetRawConfigValue(const char* name, int default_value) -> int { try { return static_cast_check_fit(Python::GetPyInt64(value)); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Expected an int value for config value '" + std::string(name) + "'."); return default_value; } @@ -398,7 +401,8 @@ auto BasePython::GetRawConfigValue(const char* name, bool default_value) try { return Python::GetPyBool(value); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Expected a bool value for config value '" + std::string(name) + "'."); return default_value; } @@ -506,16 +510,16 @@ auto BasePython::GetResource(const char* key, const char* fallback_resource, try { return g_base->python->GetPyLString(results.Get()); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, - "GetResource failed for '" + std::string(key) + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetResource failed for '" + std::string(key) + "'"); // Hmm; I guess let's just return the key to help identify/fix the // issue?.. return std::string(""; } } else { - Log(LogName::kBa, LogLevel::kError, - "GetResource failed for '" + std::string(key) + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetResource failed for '" + std::string(key) + "'"); } // Hmm; I guess let's just return the key to help identify/fix the issue?.. @@ -535,12 +539,13 @@ auto BasePython::GetTranslation(const char* category, const char* s) try { return g_base->python->GetPyLString(results.Get()); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, - "GetTranslation failed for '" + std::string(category) + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetTranslation failed for '" + std::string(category) + "'"); return ""; } } else { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "GetTranslation failed for category '" + std::string(category) + "'"); } return ""; @@ -556,7 +561,7 @@ void BasePython::RunDeepLink(const std::string& url) { .Get(base::BasePython::ObjID::kAppHandleDeepLinkCall) .Call(args); } else { - Log(LogName::kBa, LogLevel::kError, "Error on deep-link call"); + g_core->Log(LogName::kBa, LogLevel::kError, "Error on deep-link call"); } } @@ -577,8 +582,8 @@ auto BasePython::CanPyStringEditAdapterBeReplaced(PyObject* o) -> bool { .Get(BasePython::ObjID::kStringEditAdapterCanBeReplacedCall) .Call(args); if (!result.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "Error getting StringEdit valid state."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error getting StringEdit valid state."); return false; } if (result.Get() == Py_True) { @@ -587,8 +592,8 @@ auto BasePython::CanPyStringEditAdapterBeReplaced(PyObject* o) -> bool { if (result.Get() == Py_False) { return false; } - Log(LogName::kBa, LogLevel::kError, - "Got unexpected value for StringEdit valid."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got unexpected value for StringEdit valid."); return false; } diff --git a/src/ballistica/base/python/class/python_class_feature_set_data.cc b/src/ballistica/base/python/class/python_class_feature_set_data.cc index 464917af..94ee0669 100644 --- a/src/ballistica/base/python/class/python_class_feature_set_data.cc +++ b/src/ballistica/base/python/class/python_class_feature_set_data.cc @@ -2,6 +2,8 @@ #include "ballistica/base/python/class/python_class_feature_set_data.h" +#include "ballistica/base/base.h" + namespace ballistica::base { auto PythonClassFeatureSetData::type_name() -> const char* { diff --git a/src/ballistica/base/python/methods/python_methods_base_1.cc b/src/ballistica/base/python/methods/python_methods_base_1.cc index edbb1d06..ea3e8648 100644 --- a/src/ballistica/base/python/methods/python_methods_base_1.cc +++ b/src/ballistica/base/python/methods/python_methods_base_1.cc @@ -275,12 +275,12 @@ static auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) // Warn the user not to use this from the logic thread since it doesnt // save/restore context. if (!suppress_warning && g_base->InLogicThread()) { - Log(LogName::kBa, LogLevel::kWarning, - "babase.pushcall() called from the logic thread with " - "from_other_thread set to true (call " - + Python::ObjToString(call_obj) + " at " - + Python::GetPythonFileLocation() - + "). That arg should only be used from other threads."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "babase.pushcall() called from the logic thread with " + "from_other_thread set to true (call " + + Python::ObjToString(call_obj) + " at " + + Python::GetPythonFileLocation() + + "). That arg should only be used from other threads."); } assert(Python::HaveGIL()); diff --git a/src/ballistica/base/python/methods/python_methods_base_2.cc b/src/ballistica/base/python/methods/python_methods_base_2.cc index 0bdd48cb..ea6ad45e 100644 --- a/src/ballistica/base/python/methods/python_methods_base_2.cc +++ b/src/ballistica/base/python/methods/python_methods_base_2.cc @@ -190,7 +190,7 @@ static auto PyScreenMessage(PyObject* self, PyObject* args, PyObject* keywds) color = BasePython::GetPyVector3f(color_obj); } if (log) { - Log(LogName::kBa, LogLevel::kInfo, message_str); + g_core->Log(LogName::kBa, LogLevel::kInfo, message_str); } // This version simply displays it locally. diff --git a/src/ballistica/base/python/methods/python_methods_base_3.cc b/src/ballistica/base/python/methods/python_methods_base_3.cc index 43e5749f..c51bd301 100644 --- a/src/ballistica/base/python/methods/python_methods_base_3.cc +++ b/src/ballistica/base/python/methods/python_methods_base_3.cc @@ -327,8 +327,8 @@ static auto PySetUpSigInt(PyObject* self) -> PyObject* { if (g_base) { g_base->platform->SetupInterruptHandling(); } else { - Log(LogName::kBa, LogLevel::kError, - "setup_sigint called before g_base exists."); + g_core->Log(LogName::kBa, LogLevel::kError, + "setup_sigint called before g_base exists."); } Py_RETURN_NONE; BA_PYTHON_CATCH; diff --git a/src/ballistica/base/ui/dev_console.cc b/src/ballistica/base/ui/dev_console.cc index d8b57cd4..a7f8d28b 100644 --- a/src/ballistica/base/ui/dev_console.cc +++ b/src/ballistica/base/ui/dev_console.cc @@ -718,7 +718,8 @@ void DevConsole::InvokeStringEditor_() { .Get(BasePython::ObjID::kDevConsoleStringEditAdapterClass) .Call(); if (!result.Exists()) { - Log(LogName::kBa, LogLevel::kError, "Error invoking string edit dialog."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error invoking string edit dialog."); return; } @@ -1077,7 +1078,8 @@ auto DevConsole::HandleKeyRelease(const SDL_Keysym* keysym) -> bool { void DevConsole::Exec() { BA_PRECONDITION(g_base->InLogicThread()); if (!input_enabled_) { - Log(LogName::kBa, LogLevel::kWarning, "Console input is not allowed yet."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Console input is not allowed yet."); return; } input_history_position_ = 0; diff --git a/src/ballistica/base/ui/ui.cc b/src/ballistica/base/ui/ui.cc index f0ce894c..bc6ea468 100644 --- a/src/ballistica/base/ui/ui.cc +++ b/src/ballistica/base/ui/ui.cc @@ -166,13 +166,16 @@ void UI::OnAppStart() { if (force_scale_) { if (scale_ == UIScale::kSmall) { ScreenMessage("FORCING SMALL UI FOR TESTING", Vector3f(1, 0, 0)); - Log(LogName::kBa, LogLevel::kInfo, "FORCING SMALL UI FOR TESTING"); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "FORCING SMALL UI FOR TESTING"); } else if (scale_ == UIScale::kMedium) { ScreenMessage("FORCING MEDIUM UI FOR TESTING", Vector3f(1, 0, 0)); - Log(LogName::kBa, LogLevel::kInfo, "FORCING MEDIUM UI FOR TESTING"); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "FORCING MEDIUM UI FOR TESTING"); } else if (scale_ == UIScale::kLarge) { ScreenMessage("FORCING LARGE UI FOR TESTING", Vector3f(1, 0, 0)); - Log(LogName::kBa, LogLevel::kInfo, "FORCING LARGE UI FOR TESTING"); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "FORCING LARGE UI FOR TESTING"); } else { FatalError("Unhandled scale."); } @@ -577,8 +580,8 @@ void UI::ShowURL(const std::string& url) { g_base->logic->event_loop()->PushCall( [ui_delegate, url] { ui_delegate->DoShowURL(url); }); } else { - Log(LogName::kBa, LogLevel::kWarning, - "UI::ShowURL called without ui_delegate present."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "UI::ShowURL called without ui_delegate present."); } } diff --git a/src/ballistica/classic/classic.cc b/src/ballistica/classic/classic.cc index a125a41e..3b4b43c6 100644 --- a/src/ballistica/classic/classic.cc +++ b/src/ballistica/classic/classic.cc @@ -151,9 +151,9 @@ auto ClassicFeatureSet::GetV1AccountLoginStateString() -> std::string { out = "signing_in"; break; default: - Log(LogName::kBa, LogLevel::kError, - "Unknown V1LoginState '" + std::to_string(static_cast(state)) - + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Unknown V1LoginState '" + + std::to_string(static_cast(state)) + "'"); out = "signed_out"; break; } diff --git a/src/ballistica/classic/support/classic_app_mode.cc b/src/ballistica/classic/support/classic_app_mode.cc index e48238d7..607dd89f 100644 --- a/src/ballistica/classic/support/classic_app_mode.cc +++ b/src/ballistica/classic/support/classic_app_mode.cc @@ -128,10 +128,10 @@ void ClassicAppMode::Reset_() { // If all is well our sessions should all be dead at this point. if (g_scene_v1->session_count != 0) { - Log(LogName::kBa, LogLevel::kError, - "SceneV1 session count is non-zero (" - + std::to_string(g_scene_v1->session_count) - + ") on ClassicAppMode::Reset_()."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneV1 session count is non-zero (" + + std::to_string(g_scene_v1->session_count) + + ") on ClassicAppMode::Reset_()."); } // Reset the engine itself to a default state. @@ -160,16 +160,16 @@ void ClassicAppMode::HostScanCycle() { scan_socket_ = socket(AF_INET, SOCK_DGRAM, 0); if (scan_socket_ == -1) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error opening scan socket: " - + g_core->platform->GetSocketErrorString() + "."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error opening scan socket: " + + g_core->platform->GetSocketErrorString() + "."); return; } // Since this guy lives in the logic-thread we need it to not block. if (!g_core->platform->SetSocketNonBlocking(scan_socket_)) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error setting socket non-blocking."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error setting socket non-blocking."); g_core->platform->CloseSocket(scan_socket_); scan_socket_ = -1; return; @@ -184,9 +184,9 @@ void ClassicAppMode::HostScanCycle() { int result = ::bind(scan_socket_, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); if (result == 1) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error binding socket: " + g_core->platform->GetSocketErrorString() - + "."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error binding socket: " + + g_core->platform->GetSocketErrorString() + "."); g_core->platform->CloseSocket(scan_socket_); scan_socket_ = -1; return; @@ -198,9 +198,9 @@ void ClassicAppMode::HostScanCycle() { sizeof(op_val)); if (result != 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error enabling broadcast for scan-socket: " - + g_core->platform->GetSocketErrorString() + "."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error enabling broadcast for scan-socket: " + + g_core->platform->GetSocketErrorString() + "."); g_core->platform->CloseSocket(scan_socket_); scan_socket_ = -1; return; @@ -232,9 +232,9 @@ void ClassicAppMode::HostScanCycle() { case ENETUNREACH: break; default: - Log(LogName::kBaNetworking, LogLevel::kError, - "Error on scan-socket sendto: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error on scan-socket sendto: " + + g_core->platform->GetSocketErrorString()); } } } @@ -256,9 +256,9 @@ void ClassicAppMode::HostScanCycle() { case EWOULDBLOCK: break; default: - Log(LogName::kBaNetworking, LogLevel::kError, - "Error: recvfrom error: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error: recvfrom error: " + + g_core->platform->GetSocketErrorString()); break; } break; @@ -315,12 +315,12 @@ void ClassicAppMode::HostScanCycle() { PruneScanResults_(); } } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet"); } } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid BA_PACKET_HOST_QUERY_RESPONSE packet"); } } } @@ -392,8 +392,8 @@ bool ClassicAppMode::HasConnectionToClients() const { auto ClassicAppMode::GetActiveOrWarn() -> ClassicAppMode* { auto* val{GetActive()}; if (val == nullptr) { - Log(LogName::kBa, LogLevel::kWarning, - "Attempting to access ClassicAppMode while it is inactive."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Attempting to access ClassicAppMode while it is inactive."); } return val; } @@ -573,9 +573,9 @@ void ClassicAppMode::StepDisplayTime() { // Complain when our full update takes longer than 1/60th second. if (duration > (1000 / 60)) { - Log(LogName::kBa, LogLevel::kInfo, - "Logic::StepDisplayTime update took too long (" - + std::to_string(duration) + " ms)."); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "Logic::StepDisplayTime update took too long (" + + std::to_string(duration) + " ms)."); // Limit these if we want (not doing so for now). next_long_update_report_time_ = app_time; @@ -1230,8 +1230,8 @@ void ClassicAppMode::PruneSessions_() { try { i.Clear(); } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, - "Exception killing Session: " + std::string(e.what())); + g_core->Log(LogName::kBa, LogLevel::kError, + "Exception killing Session: " + std::string(e.what())); } have_dead_session = true; } @@ -1418,8 +1418,8 @@ void ClassicAppMode::HandleQuitOnIdle_() { if (!idle_exiting_ && idle_seconds > (idle_exit_minutes_.value() * 60.0f)) { idle_exiting_ = true; - Log(LogName::kBa, LogLevel::kInfo, - "Quitting due to reaching idle-exit-minutes."); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "Quitting due to reaching idle-exit-minutes."); g_base->logic->event_loop()->PushCall([] { g_base->logic->Shutdown(); }); } } @@ -1478,8 +1478,8 @@ void ClassicAppMode::HandleGameQuery(const char* buffer, size_t size, BA_PRECONDITION_FATAL(!usid.empty()); if (usid.size() > 100) { - Log(LogName::kBa, LogLevel::kError, - "had to truncate session-id; shouldn't happen"); + g_core->Log(LogName::kBa, LogLevel::kError, + "had to truncate session-id; shouldn't happen"); usid.resize(100); } if (usid.empty()) { @@ -1505,9 +1505,9 @@ void ClassicAppMode::HandleGameQuery(const char* buffer, size_t size, g_base->network_writer->PushSendToCall(msg_buffer, SockAddr(*from)); } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid game-query packet of len " + std::to_string(size) - + "; expected 5."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid game-query packet of len " + std::to_string(size) + + "; expected 5."); } } diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index 0eaf4499..111be9f1 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -11,6 +11,7 @@ #include "ballistica/core/platform/core_platform.h" #include "ballistica/core/python/core_python.h" #include "ballistica/shared/foundation/inline.h" +#include "ballistica/shared/foundation/logging.h" #include "ballistica/shared/foundation/macros.h" #include "ballistica/shared/foundation/types.h" #include "ballistica/shared/generic/runnable.h" @@ -230,7 +231,7 @@ auto CoreFeatureSet::CalcBuildSrcDir_() -> std::string { "core" BA_DIRSLASH "core.cc"); if (!f_end) { Log(LogName::kBa, LogLevel::kWarning, - "Unable to calc build source dir from __FILE__."); + [] { return "Unable to calc build source dir from __FILE__."; }); return ""; } else { return std::string(f).substr(0, f_end - f); @@ -280,14 +281,16 @@ void CoreFeatureSet::RunSanityChecks_() { // from. Use this to adjust the filtering as necessary so the resulting // type name matches what is expected. if (explicit_bool(false)) { - Log(LogName::kBa, LogLevel::kError, - "static_type_name check; name is '" - + static_type_name() + "' debug_full is '" - + static_type_name(true) + "'"); - Log(LogName::kBa, LogLevel::kError, - "static_type_name check; name is '" - + static_type_name() + "' debug_full is '" - + static_type_name(true) + "'"); + Log(LogName::kBa, LogLevel::kError, [] { + return "static_type_name check; name is '" + + static_type_name() + "' debug_full is '" + + static_type_name(true) + "'"; + }); + Log(LogName::kBa, LogLevel::kError, [] { + return "static_type_name check; name is '" + + static_type_name() + "' debug_full is '" + + static_type_name(true) + "'"; + }); } if (vr_mode_ && !g_buildconfig.vr_build()) { @@ -324,6 +327,30 @@ void CoreFeatureSet::LifecycleLog(const char* msg, double offset_seconds) { } } +void CoreFeatureSet::Log(LogName name, LogLevel level, char* msg) { + // Avoid touching the Python layer if the log will get ignored there + // anyway. + if (LogLevelEnabled(name, level)) { + Logging::Log(name, level, msg); + } +} + +void CoreFeatureSet::Log(LogName name, LogLevel level, const char* msg) { + // Avoid touching the Python layer if the log will get ignored there + // anyway. + if (LogLevelEnabled(name, level)) { + Logging::Log(name, level, msg); + } +} + +void CoreFeatureSet::Log(LogName name, LogLevel level, const std::string& msg) { + // Avoid touching the Python layer if the log will get ignored there + // anyway. + if (LogLevelEnabled(name, level)) { + Logging::Log(name, level, msg); + } +} + auto CoreFeatureSet::HeadlessMode() -> bool { // This is currently a hard-coded value but could theoretically change // later if we support running in headless mode from a gui build/etc. diff --git a/src/ballistica/core/core.h b/src/ballistica/core/core.h index bf8e177a..6dfc3487 100644 --- a/src/ballistica/core/core.h +++ b/src/ballistica/core/core.h @@ -208,10 +208,22 @@ class CoreFeatureSet { return ba_env_launch_timestamp_; } + void Log(LogName name, LogLevel level, const std::string& msg); + void Log(LogName name, LogLevel level, const char* msg); + void Log(LogName name, LogLevel level, char* msg); + + template + void Log(LogName name, LogLevel level, C getmsgcall) { + if (!LogLevelEnabled(name, level)) { + return; + } + Log(name, level, getmsgcall()); + } + private: explicit CoreFeatureSet(CoreConfig config); static void DoImport_(const CoreConfig& config); - static auto CalcBuildSrcDir_() -> std::string; + auto CalcBuildSrcDir_() -> std::string; void RunSanityChecks_(); void UpdateAppTime_(); void PostInit_(); diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index 130d1f5a..abb58fe7 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -178,11 +178,12 @@ auto CorePlatform::GetLegacyDeviceUUID() -> const std::string& { if (FILE* f2 = FOpen(path.c_str(), "wb")) { size_t result = fwrite(val.c_str(), val.size(), 1, f2); if (result != 1) - Log(LogName::kBa, LogLevel::kError, "unable to write bsuuid file."); + g_core->Log(LogName::kBa, LogLevel::kError, + "unable to write bsuuid file."); fclose(f2); } else { - Log(LogName::kBa, LogLevel::kError, - "unable to open bsuuid file for writing: '" + path + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "unable to open bsuuid file for writing: '" + path + "'"); } } } @@ -192,8 +193,8 @@ auto CorePlatform::GetLegacyDeviceUUID() -> const std::string& { } auto CorePlatform::GetDeviceV1AccountUUIDPrefix() -> std::string { - Log(LogName::kBa, LogLevel::kError, - "GetDeviceV1AccountUUIDPrefix() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetDeviceV1AccountUUIDPrefix() unimplemented"); return "u"; } @@ -249,12 +250,12 @@ void CorePlatform::SetLowLevelConfigValue(const char* key, int value) { if (f) { size_t result = fwrite(out.c_str(), out.size(), 1, f); if (result != 1) - Log(LogName::kBa, LogLevel::kError, - "unable to write low level config file."); + g_core->Log(LogName::kBa, LogLevel::kError, + "unable to write low level config file."); fclose(f); } else { - Log(LogName::kBa, LogLevel::kError, - "unable to open low level config file for writing."); + g_core->Log(LogName::kBa, LogLevel::kError, + "unable to open low level config file for writing."); } } @@ -691,7 +692,8 @@ auto CorePlatform::ConvertIncomingLeaderboardScore( void CorePlatform::SubmitScore(const std::string& game, const std::string& version, int64_t score) { - Log(LogName::kBa, LogLevel::kError, "FIXME: SubmitScore() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "FIXME: SubmitScore() unimplemented"); } void CorePlatform::ReportAchievement(const std::string& achievement) {} @@ -704,8 +706,8 @@ auto CorePlatform::HaveLeaderboard(const std::string& game, void CorePlatform::ShowGameServiceUI(const std::string& show, const std::string& game, const std::string& game_version) { - Log(LogName::kBa, LogLevel::kError, - "FIXME: ShowGameServiceUI() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "FIXME: ShowGameServiceUI() unimplemented"); } void CorePlatform::AndroidSetResString(const std::string& res) { @@ -748,29 +750,30 @@ auto CorePlatform::DemangleCXXSymbol(const std::string& s) -> std::string { } void CorePlatform::ResetAchievements() { - Log(LogName::kBa, LogLevel::kError, "ResetAchievements() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "ResetAchievements() unimplemented"); } void CorePlatform::RunEvents() {} void CorePlatform::MusicPlayerPlay(PyObject* target) { - Log(LogName::kBa, LogLevel::kError, - "MusicPlayerPlay() unimplemented on this platform"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MusicPlayerPlay() unimplemented on this platform"); } void CorePlatform::MusicPlayerStop() { - Log(LogName::kBa, LogLevel::kError, - "MusicPlayerStop() unimplemented on this platform"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MusicPlayerStop() unimplemented on this platform"); } void CorePlatform::MusicPlayerShutdown() { - Log(LogName::kBa, LogLevel::kError, - "MusicPlayerShutdown() unimplemented on this platform"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MusicPlayerShutdown() unimplemented on this platform"); } void CorePlatform::MusicPlayerSetVolume(float volume) { - Log(LogName::kBa, LogLevel::kError, - "MusicPlayerSetVolume() unimplemented on this platform"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MusicPlayerSetVolume() unimplemented on this platform"); } auto CorePlatform::IsOSPlayingMusic() -> bool { return false; } @@ -792,7 +795,7 @@ void CorePlatform::SubmitAnalyticsCounts() {} void CorePlatform::SetPlatformMiscReadVals(const std::string& vals) {} void CorePlatform::ShowAd(const std::string& purpose) { - Log(LogName::kBa, LogLevel::kError, "ShowAd() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, "ShowAd() unimplemented"); } auto CorePlatform::GetHasAds() -> bool { return false; } @@ -803,7 +806,7 @@ auto CorePlatform::GetHasVideoAds() -> bool { } void CorePlatform::SignInV1(const std::string& account_type) { - Log(LogName::kBa, LogLevel::kError, "SignInV1() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, "SignInV1() unimplemented"); } void CorePlatform::V1LoginDidChange() { @@ -811,35 +814,39 @@ void CorePlatform::V1LoginDidChange() { } void CorePlatform::SignOutV1() { - Log(LogName::kBa, LogLevel::kError, "SignOutV1() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, "SignOutV1() unimplemented"); } void CorePlatform::MacMusicAppInit() { - Log(LogName::kBa, LogLevel::kError, "MacMusicAppInit() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppInit() unimplemented"); } auto CorePlatform::MacMusicAppGetVolume() -> int { - Log(LogName::kBa, LogLevel::kError, "MacMusicAppGetVolume() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppGetVolume() unimplemented"); return 0; } void CorePlatform::MacMusicAppSetVolume(int volume) { - Log(LogName::kBa, LogLevel::kError, "MacMusicAppSetVolume() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppSetVolume() unimplemented"); } void CorePlatform::MacMusicAppStop() { - Log(LogName::kBa, LogLevel::kError, "MacMusicAppStop() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppStop() unimplemented"); } auto CorePlatform::MacMusicAppPlayPlaylist(const std::string& playlist) -> bool { - Log(LogName::kBa, LogLevel::kError, - "MacMusicAppPlayPlaylist() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppPlayPlaylist() unimplemented"); return false; } auto CorePlatform::MacMusicAppGetPlaylists() -> std::list { - Log(LogName::kBa, LogLevel::kError, - "MacMusicAppGetPlaylists() unimplemented"); + g_core->Log(LogName::kBa, LogLevel::kError, + "MacMusicAppGetPlaylists() unimplemented"); return {}; } @@ -944,9 +951,9 @@ auto CorePlatform::SetSocketNonBlocking(int sd) -> bool { #else int result = fcntl(sd, F_SETFL, O_NONBLOCK); if (result != 0) { - Log(LogName::kBa, LogLevel::kError, - "Error setting non-blocking socket: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error setting non-blocking socket: " + + g_core->platform->GetSocketErrorString()); return false; } return true; diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index 4a07ac45..5167afaf 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -919,8 +919,8 @@ auto CorePlatformWindows::GetEnv(const std::string& name) // This should always succeed at this point; make noise if not. if (result == 0 || result > big_buffer.size()) { - Log(LogName::kBa, LogLevel::kError, - "GetEnv to allocated buffer failed; unexpected."); + g_core->Log(LogName::kBa, LogLevel::kError, + "GetEnv to allocated buffer failed; unexpected."); return {}; } return UTF8Encode(big_buffer.data()); @@ -998,15 +998,16 @@ std::vector CorePlatformWindows::GetBroadcastAddrs() { pIPAddrTable = static_cast(MALLOC(dwSize)); } if (pIPAddrTable == nullptr) { - Log(LogName::kBa, LogLevel::kError, - "Memory allocation failed for GetIpAddrTable\n"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Memory allocation failed for GetIpAddrTable\n"); err = true; } if (!err) { // Make a second call to GetIpAddrTable to get the actual data we want if ((dwRetVal = GetIpAddrTable(pIPAddrTable, &dwSize, 0)) != NO_ERROR) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "GetIpAddrTable failed with error " + std::to_string(dwRetVal)); err = true; } @@ -1042,9 +1043,9 @@ bool CorePlatformWindows::SetSocketNonBlocking(int sd) { unsigned long dataval = 1; // NOLINT (func signature wants long) int result = ioctlsocket(sd, FIONBIO, &dataval); if (result != 0) { - Log(LogName::kBa, LogLevel::kError, - "Error setting non-blocking socket: " - + g_core->platform->GetSocketErrorString()); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error setting non-blocking socket: " + + g_core->platform->GetSocketErrorString()); return false; } return true; diff --git a/src/ballistica/core/python/core_python.cc b/src/ballistica/core/python/core_python.cc index 95138269..2b111502 100644 --- a/src/ballistica/core/python/core_python.cc +++ b/src/ballistica/core/python/core_python.cc @@ -189,6 +189,8 @@ void CorePython::EnablePythonLoggingCalls() { assert(objs().Exists(ObjID::kLoggerBaLogCall)); assert(objs().Exists(ObjID::kLoggerBaAudio)); assert(objs().Exists(ObjID::kLoggerBaAudioLogCall)); + assert(objs().Exists(ObjID::kLoggerBaDisplayTime)); + assert(objs().Exists(ObjID::kLoggerBaDisplayTimeLogCall)); assert(objs().Exists(ObjID::kLoggerBaGraphics)); assert(objs().Exists(ObjID::kLoggerBaGraphicsLogCall)); assert(objs().Exists(ObjID::kLoggerBaLifecycle)); @@ -260,6 +262,7 @@ void CorePython::UpdateInternalLoggerLevels(LogLevel* log_levels) { {LogName::kBa, ObjID::kLoggerBa}, {LogName::kBaAudio, ObjID::kLoggerBaAudio}, {LogName::kBaGraphics, ObjID::kLoggerBaGraphics}, + {LogName::kBaDisplayTime, ObjID::kLoggerBaDisplayTime}, {LogName::kBaLifecycle, ObjID::kLoggerBaLifecycle}, {LogName::kBaAssets, ObjID::kLoggerBaAssets}, {LogName::kBaInput, ObjID::kLoggerBaInput}, @@ -439,6 +442,10 @@ void CorePython::LoggingCall(LogName logname, LogLevel loglevel, logcallobj = ObjID::kLoggerBaGraphicsLogCall; handled = true; break; + case LogName::kBaDisplayTime: + logcallobj = ObjID::kLoggerBaDisplayTimeLogCall; + handled = true; + break; case LogName::kBaAssets: logcallobj = ObjID::kLoggerBaAssetsLogCall; handled = true; diff --git a/src/ballistica/core/python/core_python.h b/src/ballistica/core/python/core_python.h index 76fd7ad5..51fd6f2d 100644 --- a/src/ballistica/core/python/core_python.h +++ b/src/ballistica/core/python/core_python.h @@ -36,6 +36,8 @@ class CorePython { kLoggerBaLogCall, kLoggerBaAudio, kLoggerBaAudioLogCall, + kLoggerBaDisplayTime, + kLoggerBaDisplayTimeLogCall, kLoggerBaGraphics, kLoggerBaGraphicsLogCall, kLoggerBaLifecycle, diff --git a/src/ballistica/scene_v1/connection/connection.cc b/src/ballistica/scene_v1/connection/connection.cc index a38c5e5e..54863869 100644 --- a/src/ballistica/scene_v1/connection/connection.cc +++ b/src/ballistica/scene_v1/connection/connection.cc @@ -156,7 +156,8 @@ void Connection::HandleGamePacketCompressed(const std::vector& data) { try { data_decompressed = g_base->huffman->decompress(data); } catch (const std::exception& e) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, std::string("Error in huffman decompression for packet: ") + e.what()); // Hmmm i guess lets just ignore this packet and keep on trucking?.. or @@ -190,8 +191,8 @@ void Connection::HandleGamePacket(const std::vector& data) { // Expect 1 byte type, 2 byte num, 3 byte acks, at least 1 byte payload. if (data.size() < 7) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid BA_PACKET_STATE packet."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid BA_PACKET_STATE packet."); return; } uint16_t num; @@ -222,8 +223,8 @@ void Connection::HandleGamePacket(const std::vector& data) { // Expect 1 byte type, 2 byte num, 2 byte unreliable-num, 3 byte acks, // at least 1 byte payload. if (data.size() < 9) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid BA_PACKET_STATE_UNRELIABLE packet."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid BA_PACKET_STATE_UNRELIABLE packet."); return; } uint16_t num, num_unreliable; @@ -244,9 +245,9 @@ void Connection::HandleGamePacket(const std::vector& data) { } default: - Log(LogName::kBaNetworking, LogLevel::kError, - "Connection got unknown packet type: " - + std::to_string(static_cast(data[0]))); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Connection got unknown packet type: " + + std::to_string(static_cast(data[0]))); break; } } @@ -441,8 +442,8 @@ void Connection::HandleMessagePacket(const std::vector& buffer) { multipart_buffer_.resize(old_size + (buffer.size() - 1)); memcpy(&(multipart_buffer_[old_size]), &(buffer[1]), buffer.size() - 1); } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "got invalid BA_MESSAGE_MULTIPART"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "got invalid BA_MESSAGE_MULTIPART"); } if (buffer[0] == BA_MESSAGE_MULTIPART_END) { if (multipart_buffer_[0] == BA_MESSAGE_MULTIPART) { diff --git a/src/ballistica/scene_v1/connection/connection_set.cc b/src/ballistica/scene_v1/connection/connection_set.cc index 78e99dbf..c76c2f94 100644 --- a/src/ballistica/scene_v1/connection/connection_set.cc +++ b/src/ballistica/scene_v1/connection/connection_set.cc @@ -31,9 +31,9 @@ void ConnectionSet::RegisterClientController(ClientControllerInterface* c) { // This shouldn't happen, but if there's already a controller registered, // detach all clients from it. if (client_controller_) { - Log(LogName::kBaNetworking, LogLevel::kError, - "RegisterClientController() called " - "but already have a controller; bad."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "RegisterClientController() called " + "but already have a controller; bad."); for (auto&& i : connections_to_clients_) { assert(i.second.Exists()); i.second->SetController(nullptr); @@ -214,8 +214,8 @@ auto ConnectionSet::GetConnectionsToClients() if (connections_to_client.second.Exists()) { connections.push_back(connections_to_client.second.Get()); } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "HAVE NONEXISTENT CONNECTION_TO_CLIENT IN LIST; UNEXPECTED"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "HAVE NONEXISTENT CONNECTION_TO_CLIENT IN LIST; UNEXPECTED"); } } return connections; @@ -274,7 +274,8 @@ void ConnectionSet::SendScreenMessageToAll(const std::string& s, float r, void ConnectionSet::PrepareForLaunchHostSession() { // If for some reason we're still attached to a host, kill the connection. if (connection_to_host_.Exists()) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Had host-connection during LaunchHostSession(); shouldn't happen."); connection_to_host_->RequestDisconnect(); connection_to_host_.Clear(); @@ -320,9 +321,9 @@ auto ConnectionSet::DisconnectClient(int client_id, int ban_seconds) -> bool { return false; } if (client_id > 255) { - Log(LogName::kBaNetworking, LogLevel::kError, - "DisconnectClient got client_id > 255 (" + std::to_string(client_id) - + ")"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "DisconnectClient got client_id > 255 (" + + std::to_string(client_id) + ")"); } else { std::vector msg_out(2); msg_out[0] = BA_MESSAGE_KICK_VOTE; @@ -410,9 +411,9 @@ void ConnectionSet::UnregisterClientController(ClientControllerInterface* c) { // This shouldn't happen. if (client_controller_ != c) { - Log(LogName::kBaNetworking, LogLevel::kError, - "UnregisterClientController() called with a non-registered " - "controller"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "UnregisterClientController() called with a non-registered " + "controller"); return; } @@ -676,8 +677,8 @@ void ConnectionSet::HandleIncomingUDPPacket(const std::vector& data_in, msg_out[0] = BA_PACKET_CLIENT_DENY; msg_out[1] = request_id; g_base->network_writer->PushSendToCall(msg_out, addr); - Log(LogName::kBaNetworking, LogLevel::kError, - "All client slots full; really?.."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "All client slots full; really?.."); break; } connection_to_client = Object::New( @@ -732,9 +733,9 @@ void ConnectionSet::SetClientInfoFromMasterServer( const std::string& client_token, PyObject* info_obj) { // NOLINTNEXTLINE (python doing bitwise math on signed int) if (!PyDict_Check(info_obj)) { - Log(LogName::kBaNetworking, LogLevel::kError, - "got non-dict for master-server client info for token " + client_token - + ": " + Python::ObjToString(info_obj)); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "got non-dict for master-server client info for token " + + client_token + ": " + Python::ObjToString(info_obj)); return; } for (ConnectionToClient* client : GetConnectionsToClients()) { diff --git a/src/ballistica/scene_v1/connection/connection_to_client.cc b/src/ballistica/scene_v1/connection/connection_to_client.cc index a68ed5fe..7a54e998 100644 --- a/src/ballistica/scene_v1/connection/connection_to_client.cc +++ b/src/ballistica/scene_v1/connection/connection_to_client.cc @@ -144,8 +144,8 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { } if (data.empty()) { - Log(LogName::kBaNetworking, LogLevel::kError, - "ConnectionToClient got data size 0."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "ConnectionToClient got data size 0."); return; } @@ -158,8 +158,8 @@ void ConnectionToClient::HandleGamePacket(const std::vector& data) { case BA_SCENEPACKET_HANDSHAKE_RESPONSE: { // We sent the client a handshake and they're responding. if (data.size() < 3) { - Log(LogName::kBaNetworking, LogLevel::kError, - "got invalid BA_SCENEPACKET_HANDSHAKE_RESPONSE"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "got invalid BA_SCENEPACKET_HANDSHAKE_RESPONSE"); return; } @@ -352,8 +352,8 @@ void ConnectionToClient::SendScreenMessage(const std::string& s, float r, void ConnectionToClient::HandleMessagePacket( const std::vector& buffer) { if (buffer.empty()) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid HandleMessagePacket."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid HandleMessagePacket."); return; } @@ -407,8 +407,8 @@ void ConnectionToClient::HandleMessagePacket( if (b) { build_number_ = b->valueint; } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "No buildnumber in clientinfo msg."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "No buildnumber in clientinfo msg."); } // Grab their token (we use this to ask the @@ -417,8 +417,8 @@ void ConnectionToClient::HandleMessagePacket( if (t) { token_ = t->valuestring; } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "No token in clientinfo msg."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "No token in clientinfo msg."); } // Newer clients also pass a peer-hash, which @@ -437,7 +437,8 @@ void ConnectionToClient::HandleMessagePacket( } cJSON_Delete(info); } else { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Got invalid json in clientinfo message: '" + std::string(reinterpret_cast(&(buffer[1]))) + "'."); @@ -506,8 +507,8 @@ void ConnectionToClient::HandleMessagePacket( // spamming before we can verify their identities) if (appmode->require_client_authentication() && !got_info_from_master_server_) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Ignoring chat message from peer with no client info."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Ignoring chat message from peer with no client info."); SendScreenMessage(R"({"r":"loadingTryAgainText"})", 1, 0, 0); } else if (last_chat_times_.size() >= 5) { chat_block_time_ = now + next_chat_block_seconds_ * 1000; @@ -604,8 +605,8 @@ void ConnectionToClient::HandleMessagePacket( GetClientInputDevice(buffer[1])) { int count = static_cast((buffer.size() - 2) / 5); if ((buffer.size() - 2) % 5 != 0) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error: invalid player-input-commands packet"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error: invalid player-input-commands packet"); break; } int index = 2; @@ -623,8 +624,8 @@ void ConnectionToClient::HandleMessagePacket( case BA_MESSAGE_REMOVE_REMOTE_PLAYER: { last_remove_player_time_ = g_core->GetAppTimeMillisecs(); if (buffer.size() != 2) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error: invalid remove-remote-player packet"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error: invalid remove-remote-player packet"); break; } if (ClientInputDevice* cid = GetClientInputDevice(buffer[1])) { @@ -639,7 +640,8 @@ void ConnectionToClient::HandleMessagePacket( host_session->RemovePlayer(player); } } else { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Unable to get ClientInputDevice for remove-remote-player msg."); } } @@ -648,8 +650,8 @@ void ConnectionToClient::HandleMessagePacket( case BA_MESSAGE_REQUEST_REMOTE_PLAYER: { if (buffer.size() != 2) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error: invalid remote-player-request packet"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error: invalid remote-player-request packet"); break; } @@ -660,7 +662,8 @@ void ConnectionToClient::HandleMessagePacket( // It should have one of our special client delegates attached. auto* cid_d = dynamic_cast(&cid->delegate()); if (!cid_d) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Can't get client-input-device-delegate in request-remote-player " "msg."); break; @@ -684,7 +687,8 @@ void ConnectionToClient::HandleMessagePacket( } else { // Either timed out or have info; let the request go through. if (still_waiting_for_auth) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "Allowing player-request without client\'s master-server " "info (build " + std::to_string(build_number_) + ")"); @@ -693,9 +697,9 @@ void ConnectionToClient::HandleMessagePacket( } } } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "ConnectionToClient got remote player" - " request but have no host session"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "ConnectionToClient got remote player" + " request but have no host session"); } break; } @@ -707,9 +711,9 @@ void ConnectionToClient::HandleMessagePacket( if (multipart_buffer_size() > 50000) { // Its not actually unknown but shhh don't tell the hackers... SendScreenMessage(R"({"r":"errorUnknownText"})", 1, 0, 0); - Log(LogName::kBaNetworking, LogLevel::kError, - "Client data limit exceeded by '" + peer_spec().GetShortName() - + "'; kicking."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Client data limit exceeded by '" + + peer_spec().GetShortName() + "'; kicking."); appmode->BanPlayer(peer_spec(), 1000 * 60); Error(""); return; @@ -800,9 +804,9 @@ void ConnectionToClient::HandleMasterServerClientInfo(PyObject* info_obj) { "{\"t\":[\"serverResponses\"," "\"Your account was rejected. Are you signed in?\"]}", 1, 0, 0); - Log(LogName::kBaNetworking, LogLevel::kError, - "Master server found no valid account for '" - + peer_spec().GetShortName() + "'; kicking."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Master server found no valid account for '" + + peer_spec().GetShortName() + "'; kicking."); // Not benning anymore. People were exploiting this by impersonating // other players using their public ids to get them banned from diff --git a/src/ballistica/scene_v1/connection/connection_to_client_udp.cc b/src/ballistica/scene_v1/connection/connection_to_client_udp.cc index f09b2ce0..b59e0c46 100644 --- a/src/ballistica/scene_v1/connection/connection_to_client_udp.cc +++ b/src/ballistica/scene_v1/connection/connection_to_client_udp.cc @@ -72,8 +72,8 @@ void ConnectionToClientUDP::HandleGamePacket( void ConnectionToClientUDP::Die() { if (did_die_) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Posting multiple die messages; probably not good."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Posting multiple die messages; probably not good."); return; } // this will actually clear the object.. diff --git a/src/ballistica/scene_v1/connection/connection_to_host.cc b/src/ballistica/scene_v1/connection/connection_to_host.cc index bf5de0eb..50412045 100644 --- a/src/ballistica/scene_v1/connection/connection_to_host.cc +++ b/src/ballistica/scene_v1/connection/connection_to_host.cc @@ -250,8 +250,8 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { g_base->python->GetRawConfigValue("Player Profiles"); PythonRef empty_dict; if (!profiles) { - Log(LogName::kBaNetworking, LogLevel::kError, - "No profiles found; sending empty list to host"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "No profiles found; sending empty list to host"); empty_dict.Steal(PyDict_New()); profiles = empty_dict.Get(); } @@ -265,8 +265,8 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { .Get(core::CorePython::ObjID::kJsonDumpsCall) .Call(args, keywds); if (!results.Exists()) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Error getting json dump of local profiles"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Error getting json dump of local profiles"); } else { try { // Pull the string as utf8 and send. @@ -276,15 +276,16 @@ void ConnectionToHost::HandleGamePacket(const std::vector& data) { memcpy(&(msg[1]), &s[0], s.size()); SendReliableMessage(msg); } catch (const std::exception& e) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, std::string("Error sending player profiles to host: ") + e.what()); } } } } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Connected to old protocol; can't send player profiles"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Connected to old protocol; can't send player profiles"); } } break; @@ -311,8 +312,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { assert(g_base->InLogicThread()); if (buffer.empty()) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Got invalid HandleMessagePacket"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Got invalid HandleMessagePacket"); return; } @@ -336,8 +337,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { if (b) { build_number_ = b->valueint; } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "no buildnumber in hostinfo msg"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "no buildnumber in hostinfo msg"); } // Party name. cJSON* n = cJSON_GetObjectItem(info, "n"); @@ -346,8 +347,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { } cJSON_Delete(info); } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "got invalid json in hostinfo message"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "got invalid json in hostinfo message"); } } got_host_info_ = true; @@ -443,8 +444,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { case BA_MESSAGE_ATTACH_REMOTE_PLAYER_2: { // New-style packet which includes a 32-bit player_id. if (buffer.size() != 6) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Invalid attach-remote-player-2 msg"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Invalid attach-remote-player-2 msg"); break; } @@ -461,7 +462,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { delegate->AttachToRemotePlayer(this, static_cast_check_fit(player_id)); } else { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "InputDevice does not have a SceneV1 delegate as expected " "(loc1)."); } @@ -480,8 +482,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { // public servers. // TODO(ericf): can remove this once back-compat-protocol > 29. if (buffer.size() != 3) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Invalid attach-remote-player msg."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Invalid attach-remote-player msg."); break; } @@ -495,7 +497,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { &input_device->delegate())) { delegate->AttachToRemotePlayer(this, buffer[2]); } else { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "InputDevice does not have a SceneV1 delegate as expected " "(loc2)."); } @@ -513,8 +516,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { case BA_MESSAGE_DETACH_REMOTE_PLAYER: { if (buffer.size() != 2) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Invalid detach-remote-player msg"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Invalid detach-remote-player msg"); break; } // Server is telling us that our local input device is no longer @@ -538,7 +541,8 @@ void ConnectionToHost::HandleMessagePacket(const std::vector& buffer) { // be cleared out at this point. Just complain if that's not // the case. if (connection_to_host != nullptr) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "InputDevice does not have a SceneV1 delegate as expected " "(loc3)."); } diff --git a/src/ballistica/scene_v1/connection/connection_to_host_udp.cc b/src/ballistica/scene_v1/connection/connection_to_host_udp.cc index ecd4acd7..cad51ee4 100644 --- a/src/ballistica/scene_v1/connection/connection_to_host_udp.cc +++ b/src/ballistica/scene_v1/connection/connection_to_host_udp.cc @@ -125,8 +125,8 @@ void ConnectionToHostUDP::Update() { // departure before doing this when possible. void ConnectionToHostUDP::Die() { if (did_die_) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Posting multiple die messages; probably not good."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Posting multiple die messages; probably not good."); return; } if (auto* appmode = classic::ClassicAppMode::GetActiveOrWarn()) { @@ -134,9 +134,9 @@ void ConnectionToHostUDP::Die() { appmode->connections()->PushDisconnectedFromHostCall(); did_die_ = true; } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Running update for non-current host-connection; shouldn't " - "happen."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Running update for non-current host-connection; shouldn't " + "happen."); } } } diff --git a/src/ballistica/scene_v1/dynamics/dynamics.cc b/src/ballistica/scene_v1/dynamics/dynamics.cc index 8e6d1ee1..d8d1bbc8 100644 --- a/src/ballistica/scene_v1/dynamics/dynamics.cc +++ b/src/ballistica/scene_v1/dynamics/dynamics.cc @@ -143,9 +143,9 @@ Dynamics::Dynamics(Scene* scene_in) Dynamics::~Dynamics() { if (in_process_) { - Log(LogName::kBa, LogLevel::kError, - "Dynamics going down within Process() call;" - " should not happen."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Dynamics going down within Process() call;" + " should not happen."); } ShutdownODE_(); } diff --git a/src/ballistica/scene_v1/dynamics/material/material_component.cc b/src/ballistica/scene_v1/dynamics/material/material_component.cc index 2942d81a..e651fce1 100644 --- a/src/ballistica/scene_v1/dynamics/material/material_component.cc +++ b/src/ballistica/scene_v1/dynamics/material/material_component.cc @@ -215,9 +215,9 @@ void MaterialComponent::Restore(const char** buffer, ClientSession* cs) { action = Object::New(); break; default: - Log(LogName::kBa, LogLevel::kError, - "Invalid material action: '" - + std::to_string(static_cast(type)) + "'."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Invalid material action: '" + + std::to_string(static_cast(type)) + "'."); throw Exception(); } action->Restore(buffer, cs); diff --git a/src/ballistica/scene_v1/dynamics/part.cc b/src/ballistica/scene_v1/dynamics/part.cc index 8a5b1ada..2314a04d 100644 --- a/src/ballistica/scene_v1/dynamics/part.cc +++ b/src/ballistica/scene_v1/dynamics/part.cc @@ -99,8 +99,8 @@ void Part::SetCollidingWith(int64_t node_id, int part, bool colliding, for (auto&& i : collisions_) { if (i.node == node_id && i.part == part) { BA_PRECONDITION(node()); - Log(LogName::kBa, LogLevel::kError, - "Got SetCollidingWith for part already colliding with."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got SetCollidingWith for part already colliding with."); return; } } @@ -120,9 +120,9 @@ void Part::SetCollidingWith(int64_t node_id, int part, bool colliding, return; } } - Log(LogName::kBa, LogLevel::kError, - "Got SetCollidingWith (separated) call for part we're " - "not colliding with."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Got SetCollidingWith (separated) call for part we're " + "not colliding with."); } } diff --git a/src/ballistica/scene_v1/dynamics/rigid_body.cc b/src/ballistica/scene_v1/dynamics/rigid_body.cc index 66c46583..17ac13c1 100644 --- a/src/ballistica/scene_v1/dynamics/rigid_body.cc +++ b/src/ballistica/scene_v1/dynamics/rigid_body.cc @@ -212,7 +212,7 @@ void RigidBody::Check() { if (std::isnan(q[3])) err = true; if (err) { - Log(LogName::kBa, LogLevel::kError, "Got error in rbd values!"); + g_core->Log(LogName::kBa, LogLevel::kError, "Got error in rbd values!"); } #if BA_DEBUG_BUILD for (int i = 0; i < 3; i++) { diff --git a/src/ballistica/scene_v1/node/globals_node.cc b/src/ballistica/scene_v1/node/globals_node.cc index 91763abe..a167c1de 100644 --- a/src/ballistica/scene_v1/node/globals_node.cc +++ b/src/ballistica/scene_v1/node/globals_node.cc @@ -112,9 +112,9 @@ GlobalsNode::GlobalsNode(Scene* scene) : Node(scene, node_type) { // FIXME: Need to update this for non-host activities at some point. if (HostActivity* ha = context_ref().GetHostActivity()) { if (ha->globals_node()) { - Log(LogName::kBa, LogLevel::kWarning, - "More than one globals node created in HostActivity; this " - "shouldn't happen"); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "More than one globals node created in HostActivity; this " + "shouldn't happen"); } ha->SetGlobalsNode(this); diff --git a/src/ballistica/scene_v1/node/node.cc b/src/ballistica/scene_v1/node/node.cc index 27be238f..14172753 100644 --- a/src/ballistica/scene_v1/node/node.cc +++ b/src/ballistica/scene_v1/node/node.cc @@ -18,8 +18,8 @@ namespace ballistica::scene_v1 { NodeType::~NodeType() { - Log(LogName::kBa, LogLevel::kError, - "SHOULD NOT BE DESTRUCTING A TYPE type=(" + name_ + ")"); + g_core->Log(LogName::kBa, LogLevel::kError, + "SHOULD NOT BE DESTRUCTING A TYPE type=(" + name_ + ")"); } Node::Node(Scene* scene_in, NodeType* node_type) @@ -265,7 +265,8 @@ void Node::DispatchOutOfBoundsMessage() { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node OutOfBoundsMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating OutOfBoundsMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating OutOfBoundsMessage"); } } @@ -282,7 +283,7 @@ void Node::DispatchPickUpMessage(Node* node) { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node PickUpMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating PickUpMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, "Error creating PickUpMessage"); } } @@ -297,7 +298,7 @@ void Node::DispatchDropMessage() { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node DropMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating DropMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, "Error creating DropMessage"); } } @@ -315,7 +316,8 @@ void Node::DispatchPickedUpMessage(Node* by_node) { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node PickedUpMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating PickedUpMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating PickedUpMessage"); } } @@ -333,7 +335,8 @@ void Node::DispatchDroppedMessage(Node* by_node) { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node DroppedMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating DroppedMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating DroppedMessage"); } } @@ -348,7 +351,8 @@ void Node::DispatchShouldShatterMessage() { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node ShouldShatterMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating ShouldShatterMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating ShouldShatterMessage"); } } @@ -364,7 +368,8 @@ void Node::DispatchImpactDamageMessage(float intensity) { if (instance.Exists()) { DispatchUserMessage(instance.Get(), "Node ImpactDamageMessage dispatch"); } else { - Log(LogName::kBa, LogLevel::kError, "Error creating ImpactDamageMessage"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating ImpactDamageMessage"); } } @@ -392,10 +397,10 @@ void Node::DispatchUserMessage(PyObject* obj, const char* label) { c.Call(PythonRef(Py_BuildValue("(O)", obj), PythonRef::kSteal)); } } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, - std::string("Error in handlemessage() with message ") - + PythonRef(obj, PythonRef::kAcquire).Str() + ": '" + e.what() - + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + std::string("Error in handlemessage() with message ") + + PythonRef(obj, PythonRef::kAcquire).Str() + ": '" + + e.what() + "'"); } } } diff --git a/src/ballistica/scene_v1/node/node_attribute.cc b/src/ballistica/scene_v1/node/node_attribute.cc index 84c912ab..ab078822 100644 --- a/src/ballistica/scene_v1/node/node_attribute.cc +++ b/src/ballistica/scene_v1/node/node_attribute.cc @@ -52,7 +52,8 @@ auto NodeAttributeUnbound::GetNodeAttributeTypeName(NodeAttributeType t) case NodeAttributeType::kCollisionMeshArray: return "collision-mesh-array"; default: - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Unknown attr type name: " + std::to_string(static_cast(t))); return "unknown"; } @@ -102,8 +103,8 @@ void NodeAttributeUnbound::DisconnectIncoming(Node* node) { #if BA_DEBUG_BUILD if (test_ref.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "Attr connection still exists after ref releases!"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Attr connection still exists after ref releases!"); } #endif } diff --git a/src/ballistica/scene_v1/node/node_attribute_connection.cc b/src/ballistica/scene_v1/node/node_attribute_connection.cc index 95d4bf5f..a4495ce4 100644 --- a/src/ballistica/scene_v1/node/node_attribute_connection.cc +++ b/src/ballistica/scene_v1/node/node_attribute_connection.cc @@ -97,13 +97,13 @@ void NodeAttributeConnection::Update() { src_node->type()->GetAttribute(src_attr_index); NodeAttributeUnbound* dst_attr = dst_node->type()->GetAttribute(dst_attr_index); - Log(LogName::kBa, LogLevel::kError, - "Attribute connection update: " + std::string(e.what()) - + "; srcAttr='" + src_attr->name() + "', src_node='" - + src_node->type()->name() + "', srcNodeName='" - + src_node->label() + "', dstAttr='" + dst_attr->name() - + "', dstNode='" + dst_node->type()->name() + "', dstNodeName='" - + dst_node->label() + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Attribute connection update: " + std::string(e.what()) + + "; srcAttr='" + src_attr->name() + "', src_node='" + + src_node->type()->name() + "', srcNodeName='" + + src_node->label() + "', dstAttr='" + dst_attr->name() + + "', dstNode='" + dst_node->type()->name() + + "', dstNodeName='" + dst_node->label() + "'"); } } } diff --git a/src/ballistica/scene_v1/node/prop_node.cc b/src/ballistica/scene_v1/node/prop_node.cc index 71aa0a66..5fc40e6b 100644 --- a/src/ballistica/scene_v1/node/prop_node.cc +++ b/src/ballistica/scene_v1/node/prop_node.cc @@ -274,8 +274,8 @@ void PropNode::SetBody(const std::string& val) { // we're ok with redundant sets, but complain/ignore if they try to switch.. if (body_.Exists()) { if (body_type_ != body_type || shape_ != shape) { - Log(LogName::kBa, LogLevel::kError, - "body attr can not be changed from its initial value"); + g_core->Log(LogName::kBa, LogLevel::kError, + "body attr can not be changed from its initial value"); return; } } @@ -436,9 +436,9 @@ void PropNode::Step() { if (body_type_ == BodyType::UNSET) { if (!reported_unset_body_type_) { reported_unset_body_type_ = true; - Log(LogName::kBa, LogLevel::kError, - "prop-node " + GetObjectDescription() - + " did not have its 'body' attr set."); + g_core->Log(LogName::kBa, LogLevel::kError, + "prop-node " + GetObjectDescription() + + " did not have its 'body' attr set."); return; } } diff --git a/src/ballistica/scene_v1/node/spaz_node.cc b/src/ballistica/scene_v1/node/spaz_node.cc index dca3f7e6..303ad110 100644 --- a/src/ballistica/scene_v1/node/spaz_node.cc +++ b/src/ballistica/scene_v1/node/spaz_node.cc @@ -5977,8 +5977,8 @@ auto SpazNode::GetRigidBody(int id) -> RigidBody* { return hair_ponytail_bottom_body_.Get(); break; default: - Log(LogName::kBa, LogLevel::kError, - "Request for unknown spaz body: " + std::to_string(id)); + g_core->Log(LogName::kBa, LogLevel::kError, + "Request for unknown spaz body: " + std::to_string(id)); break; } @@ -6698,25 +6698,30 @@ void SpazNode::SetHoldNode(Node* val) { assert(dynamics); Collision* c = dynamics->active_collision(); if (c) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "SRC NODE: " + ObjToString(dynamics->GetActiveCollideSrcNode())); - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "OPP NODE: " + ObjToString(dynamics->GetActiveCollideDstNode())); - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "SRC BODY " + std::to_string(dynamics->GetCollideMessageReverseOrder() ? c->body_id_1 : c->body_id_2)); - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "OPP BODY " + std::to_string(dynamics->GetCollideMessageReverseOrder() ? c->body_id_2 : c->body_id_1)); - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "REVERSE " + std::to_string(dynamics->GetCollideMessageReverseOrder())); } else { - Log(LogName::kBa, LogLevel::kError, ""); + g_core->Log(LogName::kBa, LogLevel::kError, ""); } } throw Exception("specified hold_body (" + std::to_string(hold_body_) diff --git a/src/ballistica/scene_v1/python/class/python_class_input_device.cc b/src/ballistica/scene_v1/python/class/python_class_input_device.cc index 82dd67d3..eda254a4 100644 --- a/src/ballistica/scene_v1/python/class/python_class_input_device.cc +++ b/src/ballistica/scene_v1/python/class/python_class_input_device.cc @@ -438,8 +438,8 @@ auto PythonClassInputDevice::GetButtonName(PythonClassInputDevice* self, .Get(base::BasePython::ObjID::kLstrFromJsonCall) .Call(args2); if (!results.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "Error creating Lstr from raw button name: '" + bname + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating Lstr from raw button name: '" + bname + "'"); PythonRef args3(Py_BuildValue("(s)", "?"), PythonRef::kSteal); results = g_base->python->objs() .Get(base::BasePython::ObjID::kLstrFromJsonCall) diff --git a/src/ballistica/scene_v1/python/methods/python_methods_scene.cc b/src/ballistica/scene_v1/python/methods/python_methods_scene.cc index b39894f5..2a972b9b 100644 --- a/src/ballistica/scene_v1/python/methods/python_methods_scene.cc +++ b/src/ballistica/scene_v1/python/methods/python_methods_scene.cc @@ -653,7 +653,7 @@ static auto PyBroadcastMessage(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } if (log) { - Log(LogName::kBaNetworking, LogLevel::kInfo, message); + g_core->Log(LogName::kBaNetworking, LogLevel::kInfo, message); } // Transient messages get sent to clients as high-level messages instead of @@ -751,8 +751,8 @@ static auto PyBroadcastMessage(PyObject* self, PyObject* args, PyObject* keywds) tint_color.x, tint_color.y, tint_color.z, tint2_color.x, tint2_color.y, tint2_color.z); } else { - Log(LogName::kBaNetworking, LogLevel::kError, - "Unhandled screenmessage output_stream case."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Unhandled screenmessage output_stream case."); } } @@ -862,7 +862,7 @@ static auto PyPrintNodes(PyObject* self, PyObject* args) -> PyObject* { snprintf(buffer, sizeof(buffer), "#%d: type: %-14s desc: %s", count, i->type()->name().c_str(), i->label().c_str()); s += buffer; - Log(LogName::kBa, LogLevel::kInfo, buffer); + g_core->Log(LogName::kBa, LogLevel::kInfo, buffer); count++; } Py_RETURN_NONE; diff --git a/src/ballistica/scene_v1/python/scene_v1_python.cc b/src/ballistica/scene_v1/python/scene_v1_python.cc index a4f9750b..0149a238 100644 --- a/src/ballistica/scene_v1/python/scene_v1_python.cc +++ b/src/ballistica/scene_v1/python/scene_v1_python.cc @@ -367,10 +367,10 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* { attr_vals.emplace_back( t->GetAttribute(std::string(PyUnicode_AsUTF8(key))), value); } catch (const std::exception&) { - Log(LogName::kBa, LogLevel::kError, - "Attr not found on initial attr set: '" - + std::string(PyUnicode_AsUTF8(key)) + "' on " + type - + " node '" + name + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Attr not found on initial attr set: '" + + std::string(PyUnicode_AsUTF8(key)) + "' on " + type + + " node '" + name + "'"); } } @@ -380,9 +380,9 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* { try { SetNodeAttr(node, i.first->name().c_str(), i.second); } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, - "Exception in initial attr set for attr '" + i.first->name() - + "' on " + type + " node '" + name + "':" + e.what()); + g_core->Log(LogName::kBa, LogLevel::kError, + "Exception in initial attr set for attr '" + i.first->name() + + "' on " + type + " node '" + name + "':" + e.what()); } } } @@ -395,12 +395,12 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* { if (PythonClassNode::Check(owner_obj)) { Node* owner_node = GetPyNode(owner_obj, true); if (owner_node == nullptr) { - Log(LogName::kBa, LogLevel::kError, - "Empty node-ref passed for 'owner'; pass None if you want " - "no owner."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Empty node-ref passed for 'owner'; pass None if you want " + "no owner."); } else if (owner_node->scene() != node->scene()) { - Log(LogName::kBa, LogLevel::kError, - "Owner node is from a different scene; ignoring."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Owner node is from a different scene; ignoring."); } else { owner_node->AddDependentNode(node); } @@ -420,9 +420,9 @@ auto SceneV1Python::DoNewNode(PyObject* args, PyObject* keywds) -> Node* { } node->OnCreate(); } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, - "Exception in OnCreate() for node " + ballistica::ObjToString(node) - + "':" + e.what()); + g_core->Log(LogName::kBa, LogLevel::kError, + "Exception in OnCreate() for node " + + ballistica::ObjToString(node) + "':" + e.what()); } return node; @@ -1141,7 +1141,8 @@ auto SceneV1Python::FilterChatMessage(std::string* message, int client_id) try { *message = g_base->python->GetPyLString(result.Get()); } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Error getting string from chat filter: " + std::string(e.what())); } return true; diff --git a/src/ballistica/scene_v1/support/client_input_device_delegate.cc b/src/ballistica/scene_v1/support/client_input_device_delegate.cc index 8fbcbafe..9f63cde2 100644 --- a/src/ballistica/scene_v1/support/client_input_device_delegate.cc +++ b/src/ballistica/scene_v1/support/client_input_device_delegate.cc @@ -65,7 +65,8 @@ auto ClientInputDeviceDelegate::GetClientID() const -> int { if (ConnectionToClient* c = connection_to_client_.Get()) { return c->id(); } else { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "ClientInputDevice::get_client_id(): connection_to_client no longer " "exists; returning -1.."); return -1; diff --git a/src/ballistica/scene_v1/support/client_session.cc b/src/ballistica/scene_v1/support/client_session.cc index bd60117b..63759afa 100644 --- a/src/ballistica/scene_v1/support/client_session.cc +++ b/src/ballistica/scene_v1/support/client_session.cc @@ -200,7 +200,8 @@ void ClientSession::Update(int time_advance_millisecs, double time_advance) { if (g_buildconfig.debug_build()) { if (current_cmd_ptr_ != nullptr) { if (current_cmd_ptr_ != &(current_cmd_[0]) + current_cmd_.size()) { - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "SIZE ERROR FOR CMD " + std::to_string(static_cast(current_cmd_[0])) + " expected " + std::to_string(current_cmd_.size()) @@ -969,8 +970,8 @@ auto ClientSession::GetCollisionMesh(int id) const -> SceneCollisionMesh* { } void ClientSession::Error(const std::string& description) { - Log(LogName::kBaNetworking, LogLevel::kError, - "Client session error: " + description); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "Client session error: " + description); End(); } diff --git a/src/ballistica/scene_v1/support/client_session_net.cc b/src/ballistica/scene_v1/support/client_session_net.cc index c7953b1f..ce3d34e2 100644 --- a/src/ballistica/scene_v1/support/client_session_net.cc +++ b/src/ballistica/scene_v1/support/client_session_net.cc @@ -17,9 +17,9 @@ namespace ballistica::scene_v1 { ClientSessionNet::ClientSessionNet() { // Sanity check: we should only ever be writing one replay at once. if (g_scene_v1->replay_open) { - Log(LogName::kBaNetworking, LogLevel::kError, - "g_scene_v1->replay_open true at netclient start;" - " shouldn't happen."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "g_scene_v1->replay_open true at netclient start;" + " shouldn't happen."); } assert(g_base->assets_server); @@ -33,9 +33,9 @@ ClientSessionNet::~ClientSessionNet() { if (writing_replay_) { // Sanity check: we should only ever be writing one replay at once. if (!g_scene_v1->replay_open) { - Log(LogName::kBaNetworking, LogLevel::kError, - "g_scene_v1->replay_open false at net-client close;" - " shouldn't happen."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "g_scene_v1->replay_open false at net-client close;" + " shouldn't happen."); } g_scene_v1->replay_open = false; assert(g_base->assets_server); diff --git a/src/ballistica/scene_v1/support/client_session_replay.cc b/src/ballistica/scene_v1/support/client_session_replay.cc index 890fbea9..f36be252 100644 --- a/src/ballistica/scene_v1/support/client_session_replay.cc +++ b/src/ballistica/scene_v1/support/client_session_replay.cc @@ -69,17 +69,17 @@ void ClientSessionReplay::OnClientConnected(ConnectionToClient* c) { // sanity check - abort if its on either of our lists already for (ConnectionToClient* i : connections_to_clients_) { if (i == c) { - Log(LogName::kBaNetworking, LogLevel::kError, - "ReplayClientSession::OnClientConnected()" - " got duplicate connection"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "ReplayClientSession::OnClientConnected()" + " got duplicate connection"); return; } } for (ConnectionToClient* i : connections_to_clients_ignored_) { if (i == c) { - Log(LogName::kBaNetworking, LogLevel::kError, - "ReplayClientSession::OnClientConnected()" - " got duplicate connection"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "ReplayClientSession::OnClientConnected()" + " got duplicate connection"); return; } } @@ -139,9 +139,9 @@ void ClientSessionReplay::OnClientDisconnected(ConnectionToClient* c) { return; } } - Log(LogName::kBaNetworking, LogLevel::kError, - "ReplayClientSession::OnClientDisconnected()" - " called for connection not on lists"); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "ReplayClientSession::OnClientDisconnected()" + " called for connection not on lists"); } void ClientSessionReplay::FetchMessages() { diff --git a/src/ballistica/scene_v1/support/host_activity.cc b/src/ballistica/scene_v1/support/host_activity.cc index 611b688e..951d9b1d 100644 --- a/src/ballistica/scene_v1/support/host_activity.cc +++ b/src/ballistica/scene_v1/support/host_activity.cc @@ -111,7 +111,7 @@ HostActivity::~HostActivity() { for (auto& python_call : context_calls_) s += "\n " + std::to_string(count++) + ": " + (*python_call).GetObjectDescription(); - Log(LogName::kBa, LogLevel::kWarning, s); + g_core->Log(LogName::kBa, LogLevel::kWarning, s); } } } @@ -157,28 +157,29 @@ void HostActivity::RegisterContextCall(base::PythonContextCall* call) { // If we're shutting down, just kill the call immediately. // (we turn all of our calls to no-ops as we shut down) if (shutting_down_) { - Log(LogName::kBa, LogLevel::kWarning, - "Adding call to expired activity; call will not function: " - + call->GetObjectDescription()); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Adding call to expired activity; call will not function: " + + call->GetObjectDescription()); call->MarkDead(); } } void HostActivity::Start() { if (started_) { - Log(LogName::kBa, LogLevel::kError, "HostActivity::Start() called twice."); + g_core->Log(LogName::kBa, LogLevel::kError, + "HostActivity::Start() called twice."); return; } started_ = true; if (shutting_down_) { - Log(LogName::kBa, LogLevel::kError, - "HostActivity::Start() called for shutting-down activity."); + g_core->Log(LogName::kBa, LogLevel::kError, + "HostActivity::Start() called for shutting-down activity."); return; } auto* host_session = host_session_.Get(); if (!host_session) { - Log(LogName::kBa, LogLevel::kError, - "HostActivity::Start() called with dead session."); + g_core->Log(LogName::kBa, LogLevel::kError, + "HostActivity::Start() called with dead session."); return; } // Create our step timer - gets called whenever scene should step. @@ -290,9 +291,9 @@ void HostActivity::HandleOutOfBoundsNodes() { // Make sure someone's handling our out-of-bounds messages. out_of_bounds_in_a_row_++; if (out_of_bounds_in_a_row_ > 100) { - Log(LogName::kBa, LogLevel::kWarning, - "100 consecutive out-of-bounds messages sent." - " They are probably not being handled properly"); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "100 consecutive out-of-bounds messages sent." + " They are probably not being handled properly"); int j = 0; for (auto&& i : scene()->out_of_bounds_nodes()) { j++; @@ -303,10 +304,11 @@ void HostActivity::HandleOutOfBoundsNodes() { if (delegate) { dstr = PythonRef(delegate, PythonRef::kAcquire).Str(); } - Log(LogName::kBa, LogLevel::kWarning, - " node #" + std::to_string(j) + ": type='" + n->type()->name() - + "' addr=" + Utils::PtrToString(i.Get()) + " name='" - + n->label() + "' delegate=" + dstr); + g_core->Log(LogName::kBa, LogLevel::kWarning, + " node #" + std::to_string(j) + ": type='" + + n->type()->name() + + "' addr=" + Utils::PtrToString(i.Get()) + " name='" + + n->label() + "' delegate=" + dstr); } } out_of_bounds_in_a_row_ = 0; diff --git a/src/ballistica/scene_v1/support/host_session.cc b/src/ballistica/scene_v1/support/host_session.cc index 61b73c3f..b89f4fab 100644 --- a/src/ballistica/scene_v1/support/host_session.cc +++ b/src/ballistica/scene_v1/support/host_session.cc @@ -218,8 +218,8 @@ void HostSession::RequestPlayer(SceneV1InputDeviceDelegate* device) { // Ignore if we have no Python session Obj. if (!GetSessionPyObj()) { - Log(LogName::kBaNetworking, LogLevel::kError, - "HostSession::RequestPlayer() called w/no session_py_obj_."); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + "HostSession::RequestPlayer() called w/no session_py_obj_."); return; } @@ -312,13 +312,13 @@ void HostSession::IssuePlayerLeft(Player* player) { BA_LOG_PYTHON_TRACE_ONCE("missing player on IssuePlayerLeft"); } } else { - Log(LogName::kBaNetworking, LogLevel::kWarning, - "HostSession: IssuePlayerLeft caled with no " - "session_py_obj_"); + g_core->Log(LogName::kBaNetworking, LogLevel::kWarning, + "HostSession: IssuePlayerLeft caled with no " + "session_py_obj_"); } } catch (const std::exception& e) { - Log(LogName::kBaNetworking, LogLevel::kError, - std::string("Error calling on_player_leave(): ") + e.what()); + g_core->Log(LogName::kBaNetworking, LogLevel::kError, + std::string("Error calling on_player_leave(): ") + e.what()); } } @@ -338,9 +338,9 @@ void HostSession::SetForegroundHostActivity(HostActivity* a) { auto* appmode = classic::ClassicAppMode::GetActiveOrFatal(); if (shutting_down_) { - Log(LogName::kBa, LogLevel::kWarning, - "SetForegroundHostActivity called during session shutdown; " - "ignoring."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "SetForegroundHostActivity called during session shutdown; " + "ignoring."); return; } @@ -664,11 +664,12 @@ HostSession::~HostSession() { s += ("\n " + std::to_string(count++) + ": " + i->GetObjectDescription()); } - Log(LogName::kBa, LogLevel::kWarning, s); + g_core->Log(LogName::kBa, LogLevel::kWarning, s); } } } catch (const std::exception& e) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, "Exception in HostSession destructor: " + std::string(e.what())); } } @@ -686,9 +687,9 @@ void HostSession::RegisterContextCall(base::PythonContextCall* call) { // If we're shutting down, just kill the call immediately. // (we turn all of our calls to no-ops as we shut down). if (shutting_down_) { - Log(LogName::kBa, LogLevel::kWarning, - "Adding call to expired session; call will not function: " - + call->GetObjectDescription()); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Adding call to expired session; call will not function: " + + call->GetObjectDescription()); call->MarkDead(); } } diff --git a/src/ballistica/scene_v1/support/player_spec.cc b/src/ballistica/scene_v1/support/player_spec.cc index 0b7140a7..3f977b4b 100644 --- a/src/ballistica/scene_v1/support/player_spec.cc +++ b/src/ballistica/scene_v1/support/player_spec.cc @@ -39,8 +39,8 @@ PlayerSpec::PlayerSpec(const std::string& s) { cJSON_Delete(root_obj); } if (!success) { - Log(LogName::kBa, LogLevel::kError, - "Error creating PlayerSpec from string: '" + s + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error creating PlayerSpec from string: '" + s + "'"); name_ = ""; short_name_ = ""; // account_type_ = classic::V1AccountType::kInvalid; @@ -114,8 +114,8 @@ auto PlayerSpec::GetAccountPlayerSpec() -> PlayerSpec { } if (spec.name_.size() > 100) { // FIXME should perhaps clamp this in unicode space - Log(LogName::kBa, LogLevel::kError, - "account name size too long: '" + spec.name_ + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "account name size too long: '" + spec.name_ + "'"); spec.name_.resize(100); spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgaps3"); } @@ -127,8 +127,8 @@ auto PlayerSpec::GetDummyPlayerSpec(const std::string& name) -> PlayerSpec { spec.name_ = Utils::GetValidUTF8(name.c_str(), "bsgdps1"); if (spec.name_.size() > 100) { // FIXME should perhaps clamp this in unicode space - Log(LogName::kBa, LogLevel::kError, - "dummy player spec name too long: '" + spec.name_ + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "dummy player spec name too long: '" + spec.name_ + "'"); spec.name_.resize(100); spec.name_ = Utils::GetValidUTF8(spec.name_.c_str(), "bsgdps2"); } diff --git a/src/ballistica/scene_v1/support/scene.cc b/src/ballistica/scene_v1/support/scene.cc index 1e441e93..e67a8996 100644 --- a/src/ballistica/scene_v1/support/scene.cc +++ b/src/ballistica/scene_v1/support/scene.cc @@ -216,8 +216,8 @@ void Scene::DeleteNode(Node* node) { // Sanity test: at this point the node should be dead. #if BA_DEBUG_BUILD if (temp_weak_ref.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "Node still exists after ref release!!"); + g_core->Log(LogName::kBa, LogLevel::kError, + "Node still exists after ref release!!"); } #endif // BA_DEBUG_BUILD @@ -401,9 +401,9 @@ void Scene::DumpNodes(SessionStream* out) { break; } default: - Log(LogName::kBa, LogLevel::kError, - "Invalid attr type for Scene::DumpNodes() attr set: " - + std::to_string(static_cast(attr.type()))); + g_core->Log(LogName::kBa, LogLevel::kError, + "Invalid attr type for Scene::DumpNodes() attr set: " + + std::to_string(static_cast(attr.type()))); break; } } diff --git a/src/ballistica/scene_v1/support/scene_v1_context.cc b/src/ballistica/scene_v1/support/scene_v1_context.cc index e9d2a853..2e9ac626 100644 --- a/src/ballistica/scene_v1/support/scene_v1_context.cc +++ b/src/ballistica/scene_v1/support/scene_v1_context.cc @@ -77,8 +77,8 @@ auto SceneV1Context::NewTimer(TimeType timetype, TimerMedium length, void SceneV1Context::DeleteTimer(TimeType timetype, int timer_id) { // We throw on NewTimer; lets just ignore anything that comes // through here to avoid messing up destructors. - Log(LogName::kBa, LogLevel::kError, - "ContextTarget::DeleteTimer() called; unexpected."); + g_core->Log(LogName::kBa, LogLevel::kError, + "ContextTarget::DeleteTimer() called; unexpected."); } auto SceneV1Context::GetTime(TimeType timetype) -> millisecs_t { diff --git a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc index a318201c..b93175d8 100644 --- a/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc +++ b/src/ballistica/scene_v1/support/scene_v1_input_device_delegate.cc @@ -65,15 +65,15 @@ void SceneV1InputDeviceDelegate::RequestPlayer() { BA_PRECONDITION_FATAL(appmode); if (player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::RequestPlayer()" - " called with already-existing player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::RequestPlayer()" + " called with already-existing player"); return; } if (remote_player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::RequestPlayer() called with already-existing " - "remote-player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::RequestPlayer() called with already-existing " + "remote-player"); return; } @@ -101,17 +101,17 @@ void SceneV1InputDeviceDelegate::RequestPlayer() { // When the host-session tells us to attach to a player void SceneV1InputDeviceDelegate::AttachToLocalPlayer(Player* player) { if (player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::AttachToLocalPlayer() called with already " - "existing " - "player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::AttachToLocalPlayer() called with already " + "existing " + "player"); return; } if (remote_player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::AttachToLocalPlayer() called with already " - "existing " - "remote-player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::AttachToLocalPlayer() called with already " + "existing " + "remote-player"); return; } player_ = player; @@ -122,17 +122,17 @@ void SceneV1InputDeviceDelegate::AttachToRemotePlayer( ConnectionToHost* connection_to_host, int remote_player_id) { assert(connection_to_host); if (player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::AttachToRemotePlayer()" - " called with already existing " - "player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::AttachToRemotePlayer()" + " called with already existing " + "player"); return; } if (remote_player_.Exists()) { - Log(LogName::kBa, LogLevel::kError, - "InputDevice::AttachToRemotePlayer()" - " called with already existing " - "remote-player"); + g_core->Log(LogName::kBa, LogLevel::kError, + "InputDevice::AttachToRemotePlayer()" + " called with already existing " + "remote-player"); return; } remote_player_ = connection_to_host; diff --git a/src/ballistica/scene_v1/support/session.cc b/src/ballistica/scene_v1/support/session.cc index 75957529..76cce2b8 100644 --- a/src/ballistica/scene_v1/support/session.cc +++ b/src/ballistica/scene_v1/support/session.cc @@ -36,8 +36,8 @@ void Session::LanguageChanged() {} void Session::DebugSpeedMultChanged() {} void Session::DumpFullState(SessionStream* out) { - Log(LogName::kBa, LogLevel::kError, - "Session::DumpFullState() being called; shouldn't happen."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Session::DumpFullState() being called; shouldn't happen."); } } // namespace ballistica::scene_v1 diff --git a/src/ballistica/scene_v1/support/session_stream.cc b/src/ballistica/scene_v1/support/session_stream.cc index ca9f9b5e..cc6780dd 100644 --- a/src/ballistica/scene_v1/support/session_stream.cc +++ b/src/ballistica/scene_v1/support/session_stream.cc @@ -31,9 +31,9 @@ SessionStream::SessionStream(HostSession* host_session, bool save_replay) if (save_replay) { // Sanity check - we should only ever be writing one replay at once. if (g_scene_v1->replay_open) { - Log(LogName::kBa, LogLevel::kError, - "g_scene_v1->replay_open true at replay start;" - " shouldn't happen."); + g_core->Log(LogName::kBa, LogLevel::kError, + "g_scene_v1->replay_open true at replay start;" + " shouldn't happen."); } // We always write replays as the max protocol version we support. assert(g_base->assets_server); @@ -57,9 +57,9 @@ SessionStream::~SessionStream() { if (writing_replay_) { // Sanity check: We should only ever be writing one replay at once. if (!g_scene_v1->replay_open) { - Log(LogName::kBa, LogLevel::kError, - "g_scene_v1->replay_open false at replay close;" - " shouldn't happen."); + g_core->Log(LogName::kBa, LogLevel::kError, + "g_scene_v1->replay_open false at replay close;" + " shouldn't happen."); } g_scene_v1->replay_open = false; assert(g_base->assets_server); @@ -78,40 +78,45 @@ SessionStream::~SessionStream() { size_t count; count = GetPointerCount(scenes_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, - std::to_string(count) - + " scene graphs in output stream at shutdown"); + g_core->Log(LogName::kBa, LogLevel::kError, + std::to_string(count) + + " scene graphs in output stream at shutdown"); } count = GetPointerCount(nodes_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::to_string(count) + " nodes in output stream at shutdown"); } count = GetPointerCount(materials_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::to_string(count) + " materials in output stream at shutdown"); } count = GetPointerCount(textures_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::to_string(count) + " textures in output stream at shutdown"); } count = GetPointerCount(meshes_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::to_string(count) + " meshes in output stream at shutdown"); } count = GetPointerCount(sounds_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::to_string(count) + " sounds in output stream at shutdown"); } count = GetPointerCount(collision_meshes_); if (count != 0) { - Log(LogName::kBa, LogLevel::kError, - std::to_string(count) - + " collision_meshes in output stream at shutdown"); + g_core->Log(LogName::kBa, LogLevel::kError, + std::to_string(count) + + " collision_meshes in output stream at shutdown"); } } } @@ -122,8 +127,8 @@ auto SessionStream::GetOutMessage() const -> std::vector { assert(!host_session_); // this should only be getting used for // standalone temp ones.. if (!out_command_.empty()) { - Log(LogName::kBa, LogLevel::kError, - "SceneStream shutting down with non-empty outCommand"); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneStream shutting down with non-empty outCommand"); } return out_message_; } @@ -188,13 +193,13 @@ void SessionStream::Remove(T* val, std::vector* vec, } void SessionStream::Fail() { - Log(LogName::kBa, LogLevel::kError, "Error writing replay file"); + g_core->Log(LogName::kBa, LogLevel::kError, "Error writing replay file"); if (writing_replay_) { // Sanity check: We should only ever be writing one replay at once. if (!g_scene_v1->replay_open) { - Log(LogName::kBa, LogLevel::kError, - "g_scene_v1->replay_open false at replay close;" - " shouldn't happen."); + g_core->Log(LogName::kBa, LogLevel::kError, + "g_scene_v1->replay_open false at replay close;" + " shouldn't happen."); } assert(g_base->assets_server); g_base->assets_server->PushEndWriteReplayCall(); @@ -205,8 +210,8 @@ void SessionStream::Fail() { void SessionStream::Flush() { if (!out_command_.empty()) - Log(LogName::kBa, LogLevel::kError, - "SceneStream flushing down with non-empty outCommand"); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneStream flushing down with non-empty outCommand"); if (!out_message_.empty()) { ShipSessionCommandsMessage(); } @@ -535,8 +540,8 @@ void SessionStream::SetTime(millisecs_t t) { } millisecs_t diff = t - time_; if (diff > 255) { - Log(LogName::kBa, LogLevel::kError, - "SceneStream got time diff > 255; not expected."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneStream got time diff > 255; not expected."); diff = 255; } WriteCommandInt64(SessionCommand::kBaseTimeStep, diff); @@ -1195,15 +1200,15 @@ void SessionStream::OnClientConnected(ConnectionToClient* c) { // Sanity check - abort if its on either of our lists already. for (auto& connections_to_client : connections_to_clients_) { if (connections_to_client == c) { - Log(LogName::kBa, LogLevel::kError, - "SceneStream::OnClientConnected() got duplicate connection."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneStream::OnClientConnected() got duplicate connection."); return; } } for (auto& i : connections_to_clients_ignored_) { if (i == c) { - Log(LogName::kBa, LogLevel::kError, - "SceneStream::OnClientConnected() got duplicate connection."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SceneStream::OnClientConnected() got duplicate connection."); return; } } @@ -1256,7 +1261,8 @@ void SessionStream::OnClientDisconnected(ConnectionToClient* c) { return; } } - Log(LogName::kBaNetworking, LogLevel::kError, + g_core->Log( + LogName::kBaNetworking, LogLevel::kError, "SceneStream::OnClientDisconnected() called for connection not on " "lists"); } diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 41f698f2..e4be6bd0 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -9,7 +9,6 @@ #include "ballistica/core/python/core_python.h" #include "ballistica/core/support/base_soft.h" #include "ballistica/shared/foundation/fatal_error.h" -#include "ballistica/shared/foundation/logging.h" #include "ballistica/shared/math/vector3f.h" #include "ballistica/shared/python/python.h" #include "ballistica/shared/python/python_command.h" @@ -40,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 22052; +const int kEngineBuildNumber = 22057; const char* kEngineVersion = "1.7.37"; const int kEngineApiVersion = 9; @@ -134,13 +133,14 @@ auto MonolithicMain(const core::CoreConfig& core_config) -> int { auto env_config_duration = time3 - time2; auto base_import_duration = time4 - time3; auto start_app_duration = time5 - time4; - Log(LogName::kBa, LogLevel::kWarning, - "MonolithicMain took too long (" + std::to_string(total_duration) - + " ms; " + std::to_string(core_import_duration) - + " core-import, " + std::to_string(env_config_duration) - + " env-config, " + std::to_string(base_import_duration) - + " base-import, " + std::to_string(start_app_duration) - + " start-app)."); + core::g_core->Log(LogName::kBa, LogLevel::kWarning, [=] { + return "MonolithicMain took too long (" + std::to_string(total_duration) + + " ms; " + std::to_string(core_import_duration) + + " core-import, " + std::to_string(env_config_duration) + + " env-config, " + std::to_string(base_import_duration) + + " base-import, " + std::to_string(start_app_duration) + + " start-app)."; + }); } if (l_base->AppManagesMainThreadEventLoop()) { @@ -284,15 +284,20 @@ void FatalError(const std::string& message) { FatalError::DoFatalError(message); } -void Log(LogName name, LogLevel level, const std::string& msg) { - Logging::Log(name, level, msg); -} +// void Log(LogName name, LogLevel level, const std::string& msg) { +// Logging::Log(name, level, msg); +// } + +// void Log(LogName name, LogLevel level, std::string (*msg_generator)()) { +// Logging::Log(name, level, msg_generator()); +// } void ScreenMessage(const std::string& s, const Vector3f& color) { if (core::g_base_soft) { core::g_base_soft->ScreenMessage(s, color); } else { - Log(LogName::kBa, LogLevel::kError, + core::g_core->Log( + LogName::kBa, LogLevel::kError, "ScreenMessage called without base feature-set loaded (will be lost): '" + s + "'"); } diff --git a/src/ballistica/shared/ballistica.h b/src/ballistica/shared/ballistica.h index 755975c9..c5aa109b 100644 --- a/src/ballistica/shared/ballistica.h +++ b/src/ballistica/shared/ballistica.h @@ -88,9 +88,6 @@ void ScreenMessage(const std::string& msg, const Vector3f& color); /// Return a human-readable name for the current thread. auto CurrentThreadName() -> std::string; -/// Convenient access to Logging::Log. -void Log(LogName name, LogLevel level, const std::string& msg); - /// Log a fatal error and kill the app. Can be called from any thread at any /// time. Provided message will be shown to the user if possible. This will /// attempt to ship all accumulated logs to the master-server so the diff --git a/src/ballistica/shared/foundation/event_loop.cc b/src/ballistica/shared/foundation/event_loop.cc index 73616a8a..52a564a6 100644 --- a/src/ballistica/shared/foundation/event_loop.cc +++ b/src/ballistica/shared/foundation/event_loop.cc @@ -545,7 +545,7 @@ void EventLoop::PushThreadMessage_(const ThreadMessage_& t) { // Now log anything we accumulated safely outside of the locked section. for (auto&& log_entry : log_entries) { - Log(LogName::kBa, log_entry.first, log_entry.second); + g_core->Log(LogName::kBa, log_entry.first, log_entry.second); } } @@ -728,9 +728,9 @@ void EventLoop::AcquireGIL_() { if (debug_timing) { auto duration{core::CorePlatform::GetCurrentMillisecs() - startmillisecs}; if (duration > (1000 / 120)) { - Log(LogName::kBa, LogLevel::kInfo, - "GIL acquire took too long (" + std::to_string(duration) - + " millisecs)."); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "GIL acquire took too long (" + std::to_string(duration) + + " millisecs)."); } } } diff --git a/src/ballistica/shared/foundation/logging.cc b/src/ballistica/shared/foundation/logging.cc index c1f24393..7922dc8f 100644 --- a/src/ballistica/shared/foundation/logging.cc +++ b/src/ballistica/shared/foundation/logging.cc @@ -20,14 +20,9 @@ using core::g_core; int g_early_v1_cloud_log_writes{10}; void Logging::Log(LogName name, LogLevel level, const std::string& msg) { - BA_PRECONDITION(g_core); - - // Optimization: avoid touching Python at all if this log level isn't - // enabled. - if (!g_core->LogLevelEnabled(name, level)) { - return; - } - + // Wrappers calling us should check these bits. + assert(g_core); + assert(g_core->LogLevelEnabled(name, level)); g_core->python->LoggingCall(name, level, msg); } @@ -41,33 +36,26 @@ void Logging::EmitLog(const std::string& name, LogLevel level, double timestamp, auto rel_time{timestamp - g_core->ba_env_launch_timestamp()}; if (g_base_soft) { - // const char* loglevelname{"?"}; Vector4f logcolor; switch (level) { case LogLevel::kDebug: - // loglevelname = "D"; logcolor = Vector4f(0.0f, 0.5f, 1.0f, 1.0f); break; case LogLevel::kInfo: - // loglevelname = "I"; logcolor = Vector4f(1.0f, 1.0f, 1.0f, 1.0f); break; case LogLevel::kWarning: - // loglevelname = "W"; logcolor = Vector4f(1.0f, 0.7f, 0.0f, 1.0f); break; case LogLevel::kError: - // loglevelname = "E"; logcolor = Vector4f(1.0f, 0.0, 0.0f, 1.0f); break; case LogLevel::kCritical: - // loglevelname = "C"; logcolor = Vector4f(0.6f, 0.0, 0.25f, 1.0f); break; } char prestr[256]; snprintf(prestr, sizeof(prestr), "%.3f %s", rel_time, name.c_str()); - // std::string msgfull = prestr + msg; g_base_soft->PushDevConsolePrintCall("", 0.3f, kVector4f1); g_base_soft->PushDevConsolePrintCall( prestr, 0.75f, diff --git a/src/ballistica/shared/foundation/macros.cc b/src/ballistica/shared/foundation/macros.cc index c77b5120..b69a2635 100644 --- a/src/ballistica/shared/foundation/macros.cc +++ b/src/ballistica/shared/foundation/macros.cc @@ -15,6 +15,8 @@ namespace ballistica { +using core::g_core; + void MacroFunctionTimerEnd(core::CoreFeatureSet* corefs, millisecs_t starttime, millisecs_t time, const char* funcname) { // Currently disabling this for test builds; not really useful for @@ -25,9 +27,9 @@ void MacroFunctionTimerEnd(core::CoreFeatureSet* corefs, millisecs_t starttime, assert(corefs); millisecs_t endtime = corefs->platform->GetTicks(); if (endtime - starttime > time) { - Log(LogName::kBa, LogLevel::kWarning, - std::to_string(endtime - starttime) + " milliseconds spent in " - + funcname); + core::g_core->Log(LogName::kBa, LogLevel::kWarning, + std::to_string(endtime - starttime) + + " milliseconds spent in " + funcname); } } @@ -42,9 +44,10 @@ void MacroFunctionTimerEndThread(core::CoreFeatureSet* corefs, assert(corefs); millisecs_t endtime = corefs->platform->GetTicks(); if (endtime - starttime > time) { - Log(LogName::kBa, LogLevel::kWarning, - std::to_string(endtime - starttime) + " milliseconds spent by " - + ballistica::CurrentThreadName() + " thread in " + funcname); + g_core->Log(LogName::kBa, LogLevel::kWarning, + std::to_string(endtime - starttime) + " milliseconds spent by " + + ballistica::CurrentThreadName() + " thread in " + + funcname); } } @@ -59,9 +62,9 @@ void MacroFunctionTimerEndEx(core::CoreFeatureSet* corefs, assert(corefs); millisecs_t endtime = corefs->platform->GetTicks(); if (endtime - starttime > time) { - Log(LogName::kBa, LogLevel::kWarning, - std::to_string(endtime - starttime) + " milliseconds spent in " - + funcname + " for " + what); + g_core->Log(LogName::kBa, LogLevel::kWarning, + std::to_string(endtime - starttime) + " milliseconds spent in " + + funcname + " for " + what); } } @@ -77,10 +80,10 @@ void MacroFunctionTimerEndThreadEx(core::CoreFeatureSet* corefs, assert(corefs); millisecs_t endtime = corefs->platform->GetTicks(); if (endtime - starttime > time) { - Log(LogName::kBa, LogLevel::kWarning, - std::to_string(endtime - starttime) + " milliseconds spent by " - + ballistica::CurrentThreadName() + " thread in " + funcname - + " for " + what); + g_core->Log(LogName::kBa, LogLevel::kWarning, + std::to_string(endtime - starttime) + " milliseconds spent by " + + ballistica::CurrentThreadName() + " thread in " + funcname + + " for " + what); } } @@ -95,10 +98,10 @@ void MacroTimeCheckEnd(core::CoreFeatureSet* corefs, millisecs_t starttime, assert(corefs); millisecs_t e = corefs->platform->GetTicks(); if (e - starttime > time) { - Log(LogName::kBa, LogLevel::kWarning, - std::string(name) + " took " + std::to_string(e - starttime) - + " milliseconds; " + MacroPathFilter(corefs, file) + " line " - + std::to_string(line)); + g_core->Log(LogName::kBa, LogLevel::kWarning, + std::string(name) + " took " + std::to_string(e - starttime) + + " milliseconds; " + MacroPathFilter(corefs, file) + + " line " + std::to_string(line)); } } @@ -111,8 +114,8 @@ void MacroLogErrorNativeTrace(core::CoreFeatureSet* corefs, auto trace = corefs->platform->GetNativeStackTrace(); auto trace_s = trace ? trace->FormatForDisplay() : ""; - Log(LogName::kBa, LogLevel::kError, - std::string(buffer) + " error: " + msg + "\n" + trace_s); + g_core->Log(LogName::kBa, LogLevel::kError, + std::string(buffer) + " error: " + msg + "\n" + trace_s); } void MacroLogErrorPythonTrace(core::CoreFeatureSet* corefs, @@ -125,7 +128,8 @@ void MacroLogErrorPythonTrace(core::CoreFeatureSet* corefs, // Since our logging goes through Python anyway, we should just ask // Python do include the trace in our log call. Python::PrintStackTrace(); - Log(LogName::kBa, LogLevel::kError, std::string(buffer) + " error: " + msg); + g_core->Log(LogName::kBa, LogLevel::kError, + std::string(buffer) + " error: " + msg); } void MacroLogError(core::CoreFeatureSet* corefs, const std::string& msg, @@ -133,12 +137,13 @@ void MacroLogError(core::CoreFeatureSet* corefs, const std::string& msg, char e_buffer[2048]; snprintf(e_buffer, sizeof(e_buffer), "%s:%d:", MacroPathFilter(corefs, fname), line); - Log(LogName::kBa, LogLevel::kError, std::string(e_buffer) + " error: " + msg); + g_core->Log(LogName::kBa, LogLevel::kError, + std::string(e_buffer) + " error: " + msg); } void MacroLogPythonTrace(core::CoreFeatureSet* corefs, const std::string& msg) { Python::PrintStackTrace(); - Log(LogName::kBa, LogLevel::kError, msg); + g_core->Log(LogName::kBa, LogLevel::kError, msg); } auto MacroPathFilter(core::CoreFeatureSet* corefs, const char* filename) diff --git a/src/ballistica/shared/foundation/macros.h b/src/ballistica/shared/foundation/macros.h index a9193c34..100c4cce 100644 --- a/src/ballistica/shared/foundation/macros.h +++ b/src/ballistica/shared/foundation/macros.h @@ -104,14 +104,14 @@ } \ ((void)0) // (see 'Trailing-semicolon note' at top) -#define BA_LOG_ONCE(nm, lvl, msg) \ - { \ - static bool did_log_here{}; \ - if (!did_log_here) { \ - ::ballistica::Log(nm, lvl, msg); \ - did_log_here = true; \ - } \ - } \ +#define BA_LOG_ONCE(nm, lvl, msg) \ + { \ + static bool did_log_here{}; \ + if (!did_log_here) { \ + g_core->Log(nm, lvl, msg); \ + did_log_here = true; \ + } \ + } \ ((void)0) // (see 'Trailing-semicolon note' at top) #define BA_LOG_PYTHON_TRACE(msg) ::ballistica::MacroLogPythonTrace(g_core, msg) diff --git a/src/ballistica/shared/foundation/object.cc b/src/ballistica/shared/foundation/object.cc index 99502cae..e032335d 100644 --- a/src/ballistica/shared/foundation/object.cc +++ b/src/ballistica/shared/foundation/object.cc @@ -155,10 +155,10 @@ void Object::LsObjects() { assert(count == g_core->object_count); } } - Log(LogName::kBa, LogLevel::kInfo, s); + g_core->Log(LogName::kBa, LogLevel::kInfo, s); #else - Log(LogName::kBa, LogLevel::kInfo, - "LsObjects() only functions in debug builds."); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "LsObjects() only functions in debug builds."); #endif // BA_DEBUG_BUILD } diff --git a/src/ballistica/shared/foundation/types.h b/src/ballistica/shared/foundation/types.h index 18ffb4a4..7d7a07aa 100644 --- a/src/ballistica/shared/foundation/types.h +++ b/src/ballistica/shared/foundation/types.h @@ -287,6 +287,7 @@ enum class PyExcType : uint8_t { enum class LogName : uint8_t { kRoot, kBa, + kBaDisplayTime, kBaLifecycle, kBaAudio, kBaGraphics, diff --git a/src/ballistica/shared/generic/runnable.cc b/src/ballistica/shared/generic/runnable.cc index 809e7c9b..858ba63e 100644 --- a/src/ballistica/shared/generic/runnable.cc +++ b/src/ballistica/shared/generic/runnable.cc @@ -25,7 +25,8 @@ void Runnable::RunAndLogErrors() { } else { type_name = ""; } - Log(LogName::kBa, LogLevel::kError, + g_core->Log( + LogName::kBa, LogLevel::kError, std::string("Error in Runnable: " + type_name + ": ") + exc.what()); } } diff --git a/src/ballistica/shared/generic/timer_list.cc b/src/ballistica/shared/generic/timer_list.cc index a255feeb..0899d8be 100644 --- a/src/ballistica/shared/generic/timer_list.cc +++ b/src/ballistica/shared/generic/timer_list.cc @@ -2,6 +2,7 @@ #include "ballistica/shared/generic/timer_list.h" +#include "ballistica/core/core.h" #include "ballistica/shared/generic/runnable.h" namespace ballistica { @@ -19,17 +20,17 @@ TimerList::~TimerList() { if (g_buildconfig.debug_build()) { if (timer_count_active_ != 0) { - Log(LogName::kBa, LogLevel::kError, - "Invalid timerlist state on teardown."); + core::g_core->Log(LogName::kBa, LogLevel::kError, + "Invalid timerlist state on teardown."); } if (timer_count_inactive_ != 0) { - Log(LogName::kBa, LogLevel::kError, - "Invalid timerlist state on teardown."); + core::g_core->Log(LogName::kBa, LogLevel::kError, + "Invalid timerlist state on teardown."); } if (!((timer_count_total_ == 0) || (client_timer_ != nullptr && timer_count_total_ == 1))) { - Log(LogName::kBa, LogLevel::kError, - "Invalid timerlist state on teardown."); + core::g_core->Log(LogName::kBa, LogLevel::kError, + "Invalid timerlist state on teardown."); } } } diff --git a/src/ballistica/shared/generic/utils.cc b/src/ballistica/shared/generic/utils.cc index 02306fe0..3ad3e869 100644 --- a/src/ballistica/shared/generic/utils.cc +++ b/src/ballistica/shared/generic/utils.cc @@ -18,6 +18,8 @@ namespace ballistica { +using core::g_core; + #define USE_BAKED_RANDS 1 #if BA_OSTYPE_WINDOWS @@ -223,9 +225,9 @@ auto Utils::GetValidUTF8(const char* str, const char* loc) -> std::string { } } logged_count++; - Log(LogName::kBa, LogLevel::kError, - "GOT INVALID UTF8 SEQUENCE: (" + log_str + "); RETURNING '" + to - + "'; LOC '" + loc + "'"); + g_core->Log(LogName::kBa, LogLevel::kError, + "GOT INVALID UTF8 SEQUENCE: (" + log_str + "); RETURNING '" + + to + "'; LOC '" + loc + "'"); } } else { diff --git a/src/ballistica/shared/python/python.cc b/src/ballistica/shared/python/python.cc index af941812..46a341d1 100644 --- a/src/ballistica/shared/python/python.cc +++ b/src/ballistica/shared/python/python.cc @@ -32,6 +32,7 @@ namespace ballistica { // We implicitly use core functionality here; our behavior is undefined // if nobody has imported core yet. using core::g_base_soft; +using core::g_core; // Ignore signed bitwise stuff; python macros do it quite a bit. #pragma clang diagnostic push @@ -96,9 +97,9 @@ void Python::PrintStackTrace() { available = g_base_soft->PrintPythonStackTrace(); } if (!available) { - Log(LogName::kBa, LogLevel::kWarning, - "Python::PrintStackTrace() called before _babase set up; " - "not printing."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Python::PrintStackTrace() called before _babase set up; " + "not printing."); } } diff --git a/src/ballistica/shared/python/python_object_set.cc b/src/ballistica/shared/python/python_object_set.cc index c9afb6c4..8f6b4509 100644 --- a/src/ballistica/shared/python/python_object_set.cc +++ b/src/ballistica/shared/python/python_object_set.cc @@ -15,6 +15,7 @@ namespace ballistica { // Using core stuff implicitly here. Our behavior is undefined if core // has not yet been imported by anyone. using core::g_base_soft; +using core::g_core; PythonObjectSetBase::~PythonObjectSetBase() { // We make assumptions that ids remain valid once established. @@ -39,9 +40,9 @@ void PythonObjectSetBase::StoreObj(int id, PyObject* pyobj) { // Also make sure we're not storing an object that's already been stored. for (auto&& i : objs_) { if (i.Get() != nullptr && i.Get() == pyobj) { - Log(LogName::kBa, LogLevel::kWarning, - "Python::StoreObj() called twice for same ptr; id=" - + std::to_string(id) + "."); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "Python::StoreObj() called twice for same ptr; id=" + + std::to_string(id) + "."); } } } diff --git a/src/ballistica/shared/python/python_ref.cc b/src/ballistica/shared/python/python_ref.cc index e1c337bf..2ea62d33 100644 --- a/src/ballistica/shared/python/python_ref.cc +++ b/src/ballistica/shared/python/python_ref.cc @@ -16,6 +16,7 @@ namespace ballistica { // Note: implicitly using core globals here; our behavior is undefined // if core has not been imported by anyone yet. using core::g_base_soft; +using core::g_core; // Ignore a few things that python macros do. #pragma clang diagnostic push @@ -29,7 +30,8 @@ static void ClearPythonExceptionAndWarnIfUnset() { // avoid that situation because it opens up the possibility of us clearing // exceptions that aren't related to our nullptr. if (!PyErr_Occurred()) { - Log(LogName::kBa, LogLevel::kWarning, + g_core->Log( + LogName::kBa, LogLevel::kWarning, "A PythonRef acquire/steal call was passed nullptr but no Python " "exception is set. This situation should be avoided; only pass " "acquire/steal if it is directly due to a Python exception."); diff --git a/src/ballistica/shared/python/python_sys.h b/src/ballistica/shared/python/python_sys.h index ba8b0d56..e45ef102 100644 --- a/src/ballistica/shared/python/python_sys.h +++ b/src/ballistica/shared/python/python_sys.h @@ -67,13 +67,13 @@ ((void)0) // For use in tp_dealloc; simply prints the error. -#define BA_PYTHON_DEALLOC_CATCH \ - } \ - catch (const std::exception& e) { \ - Log(LogName::kBa, LogLevel::kError, \ - std::string("tp_dealloc exception: ") \ - + GetShortExceptionDescription(e)); \ - } \ +#define BA_PYTHON_DEALLOC_CATCH \ + } \ + catch (const std::exception& e) { \ + g_core->Log(LogName::kBa, LogLevel::kError, \ + std::string("tp_dealloc exception: ") \ + + GetShortExceptionDescription(e)); \ + } \ ((void)0) // Sets Python error and returns -1. diff --git a/src/ballistica/template_fs/python/class/python_class_hello.cc b/src/ballistica/template_fs/python/class/python_class_hello.cc index 39d13682..35586fee 100644 --- a/src/ballistica/template_fs/python/class/python_class_hello.cc +++ b/src/ballistica/template_fs/python/class/python_class_hello.cc @@ -2,6 +2,10 @@ #include "ballistica/template_fs/python/class/python_class_hello.h" +#include "ballistica/core/core.h" + +using ballistica::core::g_core; + namespace ballistica::template_fs { auto PythonClassHello::type_name() -> const char* { return "Hello"; } @@ -50,13 +54,13 @@ void PythonClassHello::tp_dealloc(PythonClassHello* self) { } PythonClassHello::PythonClassHello() { - Log(LogName::kBa, LogLevel::kInfo, - "Hello from PythonClassHello constructor!!!"); + core::g_core->Log(LogName::kBa, LogLevel::kInfo, + "Hello from PythonClassHello constructor!!!"); } PythonClassHello::~PythonClassHello() { - Log(LogName::kBa, LogLevel::kInfo, - "Goodbye from PythonClassHello destructor!!!"); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "Goodbye from PythonClassHello destructor!!!"); } auto PythonClassHello::TestMethod(PythonClassHello* self, PyObject* args, @@ -68,9 +72,9 @@ auto PythonClassHello::TestMethod(PythonClassHello* self, PyObject* args, const_cast(kwlist), &val)) { return nullptr; } - Log(LogName::kBa, LogLevel::kInfo, - "Hello from PythonClassHello.test_method!!! (val=" + std::to_string(val) - + ")"); + g_core->Log(LogName::kBa, LogLevel::kInfo, + "Hello from PythonClassHello.test_method!!! (val=" + + std::to_string(val) + ")"); Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/template_fs/python/methods/python_methods_template_fs.cc b/src/ballistica/template_fs/python/methods/python_methods_template_fs.cc index b9d1b9d7..04cb956e 100644 --- a/src/ballistica/template_fs/python/methods/python_methods_template_fs.cc +++ b/src/ballistica/template_fs/python/methods/python_methods_template_fs.cc @@ -19,7 +19,7 @@ static auto PyHelloAgainWorld(PyObject* self, PyObject* args, PyObject* keywds) &name)) { return nullptr; } - Log(LogName::kBa, LogLevel::kInfo, "HELLO AGAIN WORLD!"); + g_core->Log(LogName::kBa, LogLevel::kInfo, "HELLO AGAIN WORLD!"); Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/ui_v1/python/class/python_class_widget.cc b/src/ballistica/ui_v1/python/class/python_class_widget.cc index dadf5e74..2d65621d 100644 --- a/src/ballistica/ui_v1/python/class/python_class_widget.cc +++ b/src/ballistica/ui_v1/python/class/python_class_widget.cc @@ -301,7 +301,8 @@ auto PythonClassWidget::Delete(PythonClassWidget* self, PyObject* args, if (p) { p->DeleteWidget(w); } else { - Log(LogName::kBa, LogLevel::kError, "Can't delete widget: no parent."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Can't delete widget: no parent."); } } @@ -330,6 +331,25 @@ auto PythonClassWidget::AddDeleteCallback(PythonClassWidget* self, BA_PYTHON_CATCH; } +auto PythonClassWidget::Dir(PythonClassWidget* self) -> PyObject* { + BA_PYTHON_TRY; + + // Start with the standard Python dir listing. + PyObject* dir_list = Python::generic_dir(reinterpret_cast(self)); + assert(PyList_Check(dir_list)); + + // ..and add in our custom attr names. + for (const char** name = extra_dir_attrs; *name != nullptr; name++) { + PyList_Append( + dir_list, + PythonRef(PyUnicode_FromString(*name), PythonRef::kSteal).Get()); + } + PyList_Sort(dir_list); + return dir_list; + + BA_PYTHON_CATCH; +} + PyTypeObject PythonClassWidget::type_obj; PyMethodDef PythonClassWidget::tp_methods[] = { {"exists", (PyCFunction)Exists, METH_NOARGS, @@ -376,6 +396,8 @@ PyMethodDef PythonClassWidget::tp_methods[] = { "add_delete_callback(call: Callable) -> None\n" "\n" "Add a call to be run immediately after this widget is destroyed."}, + {"__dir__", (PyCFunction)Dir, METH_NOARGS, + "allows inclusion of our custom attrs in standard python dir()"}, {nullptr}}; } // namespace ballistica::ui_v1 diff --git a/src/ballistica/ui_v1/python/class/python_class_widget.h b/src/ballistica/ui_v1/python/class/python_class_widget.h index b4e98409..e846d80c 100644 --- a/src/ballistica/ui_v1/python/class/python_class_widget.h +++ b/src/ballistica/ui_v1/python/class/python_class_widget.h @@ -29,6 +29,7 @@ class PythonClassWidget : public PythonClass { static auto tp_getattro(PythonClassWidget* self, PyObject* attr) -> PyObject*; static auto tp_setattro(PythonClassWidget* self, PyObject* attr, PyObject* val) -> int; + static auto Dir(PythonClassWidget* self) -> PyObject*; static auto Exists(PythonClassWidget* self) -> PyObject*; static auto GetWidgetType(PythonClassWidget* self) -> PyObject*; static auto Activate(PythonClassWidget* self) -> PyObject*; diff --git a/src/ballistica/ui_v1/python/ui_v1_python.cc b/src/ballistica/ui_v1/python/ui_v1_python.cc index f5976a75..fe4a8a0a 100644 --- a/src/ballistica/ui_v1/python/ui_v1_python.cc +++ b/src/ballistica/ui_v1/python/ui_v1_python.cc @@ -78,7 +78,8 @@ void UIV1Python::ShowURL(const std::string& url) { PythonRef args(Py_BuildValue("(s)", url.c_str()), PythonRef::kSteal); objs().Get(ObjID::kShowURLWindowCall).Call(args); } else { - Log(LogName::kBa, LogLevel::kError, "ShowURLWindowCall nonexistent."); + g_core->Log(LogName::kBa, LogLevel::kError, + "ShowURLWindowCall nonexistent."); } } @@ -119,7 +120,8 @@ void UIV1Python::InvokeStringEditor(PyObject* string_edit_adapter_instance) { context_call->ScheduleInUIOperation(args); } else { // Otherwise just run immediately. - Log(LogName::kBa, LogLevel::kWarning, + g_core->Log( + LogName::kBa, LogLevel::kWarning, "UIV1Python::InvokeStringEditor running outside of UIInteraction; " "unexpected."); context_call->Run(args); diff --git a/src/ballistica/ui_v1/widget/button_widget.cc b/src/ballistica/ui_v1/widget/button_widget.cc index f70d54ce..eff91625 100644 --- a/src/ballistica/ui_v1/widget/button_widget.cc +++ b/src/ballistica/ui_v1/widget/button_widget.cc @@ -543,8 +543,8 @@ void ButtonWidget::Activate() { DoActivate(); } void ButtonWidget::DoActivate(bool is_repeat) { if (!enabled_) { - Log(LogName::kBa, LogLevel::kWarning, - "ButtonWidget::DoActivate() called on disabled button"); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "ButtonWidget::DoActivate() called on disabled button"); return; } diff --git a/src/ballistica/ui_v1/widget/container_widget.cc b/src/ballistica/ui_v1/widget/container_widget.cc index 41ed06e8..8edd9d3f 100644 --- a/src/ballistica/ui_v1/widget/container_widget.cc +++ b/src/ballistica/ui_v1/widget/container_widget.cc @@ -1402,9 +1402,9 @@ void ContainerWidget::SelectWidget(Widget* w, SelectionCause c) { } } else { if (root_selectable_) { - Log(LogName::kBa, LogLevel::kError, - "SelectWidget() called on a ContainerWidget which is itself " - "selectable. Ignoring."); + g_core->Log(LogName::kBa, LogLevel::kError, + "SelectWidget() called on a ContainerWidget which is itself " + "selectable. Ignoring."); return; } for (auto& widget : widgets_) { @@ -1429,9 +1429,9 @@ void ContainerWidget::SelectWidget(Widget* w, SelectionCause c) { } else { static bool printed = false; if (!printed) { - Log(LogName::kBa, LogLevel::kWarning, - "SelectWidget called on unselectable widget: " - + w->GetWidgetTypeName()); + g_core->Log(LogName::kBa, LogLevel::kWarning, + "SelectWidget called on unselectable widget: " + + w->GetWidgetTypeName()); Python::PrintStackTrace(); printed = true; } @@ -1634,7 +1634,8 @@ void ContainerWidget::SelectDownWidget() { } if (w) { if (!w->IsSelectable()) { - Log(LogName::kBa, LogLevel::kError, "Down_widget is not selectable."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Down_widget is not selectable."); } else { w->Show(); // Avoid tap sounds and whatnot if we're just re-selecting ourself. @@ -1699,7 +1700,8 @@ void ContainerWidget::SelectUpWidget() { } if (w) { if (!w->IsSelectable()) { - Log(LogName::kBa, LogLevel::kError, "up_widget is not selectable."); + g_core->Log(LogName::kBa, LogLevel::kError, + "up_widget is not selectable."); } else { w->Show(); // Avoid tap sounds and whatnot if we're just re-selecting ourself. @@ -1752,7 +1754,8 @@ void ContainerWidget::SelectLeftWidget() { } if (w) { if (!w->IsSelectable()) { - Log(LogName::kBa, LogLevel::kError, "left_widget is not selectable."); + g_core->Log(LogName::kBa, LogLevel::kError, + "left_widget is not selectable."); } else { w->Show(); // Avoid tap sounds and whatnot if we're just re-selecting ourself. @@ -1805,7 +1808,8 @@ void ContainerWidget::SelectRightWidget() { } if (w) { if (!w->IsSelectable()) { - Log(LogName::kBa, LogLevel::kError, "right_widget is not selectable."); + g_core->Log(LogName::kBa, LogLevel::kError, + "right_widget is not selectable."); } else { w->Show(); // Avoid tap sounds and whatnot if we're just re-selecting ourself. diff --git a/src/ballistica/ui_v1/widget/text_widget.cc b/src/ballistica/ui_v1/widget/text_widget.cc index 55a4ffd3..3658c088 100644 --- a/src/ballistica/ui_v1/widget/text_widget.cc +++ b/src/ballistica/ui_v1/widget/text_widget.cc @@ -643,7 +643,8 @@ void TextWidget::InvokeStringEditor_() { .Get(UIV1Python::ObjID::kTextWidgetStringEditAdapterClass) .Call(args); if (!result.Exists()) { - Log(LogName::kBa, LogLevel::kError, "Error invoking string edit dialog."); + g_core->Log(LogName::kBa, LogLevel::kError, + "Error invoking string edit dialog."); return; } diff --git a/src/ballistica/ui_v1/widget/widget.cc b/src/ballistica/ui_v1/widget/widget.cc index c073aa52..a03ffd42 100644 --- a/src/ballistica/ui_v1/widget/widget.cc +++ b/src/ballistica/ui_v1/widget/widget.cc @@ -193,10 +193,11 @@ void Widget::ScreenPointToWidget(float* x, float* y) const { float y_test = *y; WidgetPointToScreen(&x_test, &y_test); if (std::abs(x_test - x_old) > 0.01f || std::abs(y_test - y_old) > 0.01f) { - Log(LogName::kBa, LogLevel::kError, - "ScreenPointToWidget sanity check error: expected (" - + std::to_string(x_old) + "," + std::to_string(y_old) + ") got (" - + std::to_string(x_test) + "," + std::to_string(y_test) + ")"); + g_core->Log(LogName::kBa, LogLevel::kError, + "ScreenPointToWidget sanity check error: expected (" + + std::to_string(x_old) + "," + std::to_string(y_old) + + ") got (" + std::to_string(x_test) + "," + + std::to_string(y_test) + ")"); } #endif // BA_DEBUG_BUILD || BA_TEST_BUILD } diff --git a/src/meta/bacoremeta/pyembed/binding_core.py b/src/meta/bacoremeta/pyembed/binding_core.py index 9ec8b336..8e5db577 100644 --- a/src/meta/bacoremeta/pyembed/binding_core.py +++ b/src/meta/bacoremeta/pyembed/binding_core.py @@ -29,6 +29,8 @@ values = [ logging.getLogger('ba').log, # kLoggerBaLogCall logging.getLogger('ba.audio'), # kLoggerBaAudio logging.getLogger('ba.audio').log, # kLoggerBaAudioLogCall + logging.getLogger('ba.displaytime'), # kLoggerBaDisplayTime + logging.getLogger('ba.displaytime').log, # kLoggerBaDisplayTimeLogCall logging.getLogger('ba.graphics'), # kLoggerBaGraphics logging.getLogger('ba.graphics').log, # kLoggerBaGraphicsLogCall logging.getLogger('ba.lifecycle'), # kLoggerBaLifecycle