a bit of logging tidying

This commit is contained in:
Eric 2022-09-15 09:24:57 -07:00
parent bc59182f80
commit 3816f1dcb9
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
16 changed files with 77 additions and 72 deletions

View File

@ -3995,26 +3995,26 @@
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e",
"assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34",
"ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a5/a8/9d3491007df68a350cbde1416c19",
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cf/46/edc440b82d790bfaf6442655fb00",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/19/54/871a764ff37f2403394b64f6c67c",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5c/29/aa06b7aab528b711d6f36df7e7fe",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c0/24/d15917e364ed6d828c365146bd77",
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/78/0c/3f455338341af8e01f386064f46a",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/07/a5/18ea8943f2cd24956003a966459f",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/db/09/ab3381c7f3379ce1236863bdd59d",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b1/8c/fd9dc45ba9d875f7831d071a0caf",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/16/b7/c3dc3b169eac2f903ef30ed1cad5",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/19/0a/0cc50f509eee00a19976d3729290",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d8/37/4e73e8e866c6152a0dfcb0f71ec8",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c4/3d/612c9aa69aab61b0a8422fe3b5e2",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6c/ff/e6e882a7675d7e4466d0ba429180",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1e/d8/c29cb8b89ea52683859e72c98786",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a6/e7/02ef6d8e0a808c9f69544c25db09",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/d3/44/210d37b4577a1fd4fc4ca63913ca",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/29/d7/6cb90c1c86b2a466020e8c11d3fc",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/25/22/d3ceba9f8502a410c25665f7b0ae",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/17/4e/3c1b5f065732a4aa8d6f4bc71589",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/15/b2/0744afc264f1e55a5944bf8ae964",
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/8e/98/ea10bd892f89c7ba5aec76721667",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/aa/e4/7c73515c9044e051a5d07cb1e964",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ba/37/245e7c3dc79588d73a57f9f08b55",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ad/28/034d014eea6aeba4b67d51cfc262",
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/77/df/c85dfe5cb062b6925da7df8e740c",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/58/6b/058b05227950f5d83f23b01617d1",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bd/31/02ecb4d8c3bea8eb68d92befdd9d",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/aa/9d/96555101ebf8b14223b7639cea5b",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/1d/9a/16feda78b815cbed47b89983c48e",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b0/31/f60dc64681a35406595ed4836f0a",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b5/44/eb4645945794253446c55dc682bc",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/43/56/592cd419bfad9cbbb6e3f57c1007",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c6/55/0dfcc3d90a9cee9212e2e10a91b1",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/19/c6/994729e095b54e6963ac2d4bbd10",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ce/21/77cd76cd1b0307ae8cc7038152e7",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a9/e6/23835561d55b6c1d1862217fc115",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/21/3d/e0a1e20ae12dd7b5ba1d61aed074",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/be/b5/fc827900f411576b992fc15a25fc",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/6f/51/d6a0951b6ab9122dd99ef33d4427",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d5/f6/d62e6e6d5e7fe1945f08ccbb9a8f",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/02/c5/44d0082442b06153a7d7dce4c8ce",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d0/00/61378fb26ddcbf023fd3c40e4ffb",
@ -4031,14 +4031,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ff/26/da4a58abecf5d9275477eaec0c17",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/62/5d/8658a206b8c9b741be2422162784",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fc/57/d59920e098d23a2d150c899cde29",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/85/19/3c25e72ea3976b7d854c21696ec4",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/50/21/6c275dad22cc2cc1f95e21652c29",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/a0/1a/f894ee82b89dcb4a43c36ab882ee",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/c3/6a/0e89ae233f6ae76351d33ed2b0e6",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/ce/ba/c5a0c9b8224dc8df02c5189e22ac",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/1d/3a/560a77a6c97f6f39b765211b1ed8",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/5b/fb/b8c70b2a72452da1af92844335b8",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/a9/6c/12e1188dc02708b0b0fee30835b9",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/fb/8e/3bb1c858451a447f1a102d77c281",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/ae/ad/13ae735e45d31d2944c89e8bdcec",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/e8/3e/6c2546278ad0428965a05c9bd536",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/d4/e5/0fe217cac5837cf663c7c7f1aa92",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/ea/38/a5082d73202113900166a1ebd15f",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/ba/1c/16df69d156e23ab29e2c84465bd7",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/9e/b0/91b2e0b1dbd4541543f3f147bc06",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/c1/04/ad892d77317be76bc8fa035f9e86",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/c0/32/b7907e3859a5c5013a3d97b6b523",
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/2d/4f/f4fe67827f36cd59cd5193333a02",
"src/ballistica/generated/python_embedded/bootstrap_monolithic.inc": "https://files.ballistica.net/cache/ba1/ef/c1/aa5f1aa10af89f5c0b1e616355fd"

View File

@ -1346,6 +1346,7 @@
<w>levelgametype</w>
<w>levelmodule</w>
<w>levelname</w>
<w>levelno</w>
<w>lfull</w>
<w>lfval</w>
<w>libballisticacore</w>

View File

@ -1,4 +1,4 @@
### 1.7.7 (build 20855, api 7, 2022-09-14)
### 1.7.7 (build 20856, api 7, 2022-09-15)
- Added `ba.app.meta.load_exported_classes()` for loading classes discovered by the meta subsystem cleanly in a background thread.
- Improved logging of missing playlist game types.
- Some ba.Lstr functionality can now be used in background threads.
@ -35,6 +35,7 @@
- Added `_ba.display_log()` function which ships a log message to the in-game terminal and platform-specific places like the Android log. The engine wires up standard Python logging output to go through this.
- Added `_ba.v1_cloud_log()` which ships a message to the old v1-cloud-log (the log which is gathered and sent to the v1 master server to help me identify problems people are seeing). This is presently wired up to a subset of Python logging output to approximate how it used to work.
- Note: Previously in the C++ layer some code would mix Python print calls (such as PyErr_PrintEx()) with ballistica::Log() calls. Previously these all wound up going to the same place (Python's sys.stderr) so it worked, but now they no longer do and so this sort of mixing should be avoided. So if you see a weird combination of colored log output lines with non-colored lines that seem to go together, please holler as it means something needs to be fixed.
- Builds for Apple devices now set a thread stack size of 1MB. The default there is 512k and I was seeing some stack overflows for heavy Physics sims or very recursive Python stuff.
### 1.7.6 (build 20687, api 7, 2022-08-11)

View File

@ -43,7 +43,7 @@ def bootstrap() -> None:
# Give a soft warning if we're being used with a different binary
# version than we expect.
expected_build = 20855
expected_build = 20856
running_build: int = env['build_number']
if running_build != expected_build:
print(

View File

@ -702,6 +702,7 @@
<w>leaderboard</w>
<w>leaderboards</w>
<w>lenval</w>
<w>levelno</w>
<w>lgui</w>
<w>lhalf</w>
<w>libbz</w>

View File

@ -367,8 +367,8 @@ auto AudioServer::OnAppStartInThread() -> void {
// If the string is blank, we weren't able to find the oculus
// audio device. In that case we'll just go with default.
if (g_rift_audio_device_name != "") {
// Log("AL Devices list:");
// Log("----------");
// Log(LogLevel::kInfo, "AL Devices list:");
// Log(LogLevel::kInfo, "----------");
while (device && *device != '\0' && next && *next != '\0') {
// These names seem to be things like "OpenAL Soft on FOO"
// ..we should be able to search for FOO.
@ -379,7 +379,7 @@ auto AudioServer::OnAppStartInThread() -> void {
device += (len + 1);
next += (len + 2);
}
// Log("----------");
// Log(LogLevel::kInfo, "----------");
}
}
}

View File

@ -32,7 +32,7 @@
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kAppBuildNumber = 20855;
const int kAppBuildNumber = 20856;
const char* kAppVersion = "1.7.7";
// Our standalone globals.

View File

@ -165,9 +165,13 @@ auto InNetworkWriteThread() -> bool;
/// Return a human-readable name for the current thread.
auto GetCurrentThreadName() -> std::string;
/// Write a string to the log.
/// This will go to stdout, windows debug log, android log, etc.
/// A trailing newline will be added.
/// Submit a log entry.
/// Can be called from any thread at any time.
/// Use either this or Python printing functionality for anything
/// that should be seen by the user, as both of those will end up
/// in the in-app console, cloud based consoles, android log, etc.
/// Regular C level prints to stdout/stderr will not and will only
/// be visible on some platforms.
auto Log(LogLevel level, const std::string& msg) -> void;
/// Log a fatal error and kill the app.

View File

@ -407,7 +407,8 @@ void Huffman::decompress(const char* data, uint32_t length,
// fixme??
if (bytes > kMaxPacketSize) {
Log("HUFFMAN DECOMPRESSING TO TOO LARGE: " + std::to_string(bytes));
Log(LogLevel::kError, "HUFFMAN DECOMPRESSING TO TOO LARGE: "
+ std::to_string(bytes));
}
assert(bytes <= kMaxPacketSize);
@ -459,7 +460,7 @@ void Huffman::train(const char* buffer, int len) {
len--;
}
if (total_length > kTrainingLength) {
Log("HUFFMAN TRAINING COMPLETE:");
Log(LogLevel::kInfo, "HUFFMAN TRAINING COMPLETE:");
build();
@ -470,7 +471,7 @@ void Huffman::train(const char* buffer, int len) {
if (i < 255) s += ",";
}
s += "}";
Log("FINAL: " + s);
Log(LogLevel::kInfo, "FINAL: " + s);
}
}
#endif // HUFFMAN_TRAINING_MODE

View File

@ -24,12 +24,12 @@
#endif
#if BA_DEBUG_BUILD
#define DEBUG_CHECK_GL_ERROR \
{ \
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) \
Log("OPENGL ERROR AT LINE " + std::to_string(__LINE__) + ": " \
+ GLErrorToString(err)); \
#define DEBUG_CHECK_GL_ERROR \
{ \
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) \
Log(LogLevel::kError, "OPENGL ERROR AT LINE " + std::to_string(__LINE__) \
+ ": " + GLErrorToString(err)); \
}
#else
#define DEBUG_CHECK_GL_ERROR

View File

@ -769,7 +769,6 @@ class RendererGL::FramebufferObjectGL : public Framebuffer {
GLenum format = GL_UNSIGNED_BYTE;
#endif
// if (srgbTest) {
// Log("YOOOOOOO");
// glTexImage2D(GL_TEXTURE_2D, 0, alpha_?GL_SRGB8_ALPHA8:GL_SRGB8,
// _width, _height, 0, alpha_?GL_RGBA:GL_RGB, format, nullptr);
// } else {
@ -910,11 +909,11 @@ class RendererGL::FramebufferObjectGL : public Framebuffer {
// glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
// GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &enc); if
// (enc == GL_SRGB) {
// Log("GOT SRGB!!!!!!!!!!!");
// Log(LogLevel::kInfo, "GOT SRGB!!!!!!!!!!!");
// } else if (enc == GL_LINEAR) {
// Log("GOT LINEAR...");
// Log(LogLevel::kInfo, "GOT LINEAR...");
// } else {
// Log("GOT OTHER..");
// Log(LogLevel::kInfo, "GOT OTHER..");
// }
loaded_ = true;
}
@ -2464,7 +2463,8 @@ class RendererGL::PostProcessProgramGL : public RendererGL::ProgramGL {
s += "}";
if (flags & SHD_DEBUG_PRINT)
Log("\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
Log(LogLevel::kInfo,
"\nVertex code for shader '" + GetName(flags) + "':\n\n" + s);
return s;
}
string GetFragmentCode(int flags) {
@ -2478,7 +2478,8 @@ class RendererGL::PostProcessProgramGL : public RendererGL::ProgramGL {
s += "}";
if (flags & SHD_DEBUG_PRINT)
Log("\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
Log(LogLevel::kInfo,
"\nFragment code for shader '" + GetName(flags) + "':\n\n" + s);
return s;
}

View File

@ -1058,7 +1058,7 @@ void Input::HandleBackPress(bool from_toolbar) {
if (g_ui == nullptr || g_ui->screen_root_widget() == nullptr
|| g_ui->overlay_root_widget() == nullptr
|| g_ui->root_widget() == nullptr) {
// Log("HandleBackPress() called without main UI");
// Log(LogLevel::kError, "HandleBackPress() called without main UI");
return;
}

View File

@ -619,7 +619,7 @@ void Logic::Update() {
} else {
// If we've gone too far already, bail.
if (master_time_ >= max_target_master_time) {
// Log("BAILING EARLY");
// Log(LogLevel::kError, "BAILING EARLY");
// On rift if this is a 2-step and we bailed after 1, aim for 2 again
// next time (otherwise we'll always get 3 singles in a row when this
// happens).

View File

@ -380,8 +380,8 @@ void Player::InputCommand(InputType type, float value) {
RunInput(type, value);
break;
// case InputType::kReset:
// Log("Error: FIXME: player-input-reset command unimplemented");
// break;
// Log(LogLevel::kError, "FIXME: player-input-reset command
// unimplemented"); break;
default:
RunInput(type);
break;

View File

@ -32,7 +32,7 @@ HostSession::HostSession(PyObject* session_type_obj)
is_main_menu_ =
static_cast<bool>(strstr(Python::ObjToString(session_type_obj).c_str(),
"bastd.mainmenu.MainMenuSession"));
// Log("MAIN MENU? " + std::to_string(is_main_menu()));
// Log(LogLevel::kInfo, "MAIN MENU? " + std::to_string(is_main_menu()));
kick_idle_players_ = g_logic->kick_idle_players();

View File

@ -37,15 +37,15 @@ class LogLevel(Enum):
CRITICAL = 4
LOG_NAMES_TO_LEVELS = {
'DEBUG': LogLevel.DEBUG,
'INFO': LogLevel.INFO,
'WARNING': LogLevel.WARNING,
'ERROR': LogLevel.ERROR,
'CRITICAL': LogLevel.CRITICAL
LEVELNO_LOG_LEVELS = {
logging.DEBUG: LogLevel.DEBUG,
logging.INFO: LogLevel.INFO,
logging.WARNING: LogLevel.WARNING,
logging.ERROR: LogLevel.ERROR,
logging.CRITICAL: LogLevel.CRITICAL
}
LOG_LEVEL_NUMS_TO_COLOR_CODES: dict[int, tuple[str, str]] = {
LEVELNO_COLOR_CODES: dict[int, tuple[str, str]] = {
logging.DEBUG: (TerminalColor.CYAN.value, TerminalColor.RESET.value),
logging.INFO: ('', ''),
logging.WARNING: (TerminalColor.YELLOW.value, TerminalColor.RESET.value),
@ -150,24 +150,20 @@ class LogHandler(logging.Handler):
if self._echofile is not None:
cbegin: str
cend: str
cbegin, cend = LOG_LEVEL_NUMS_TO_COLOR_CODES.get(
record.levelno, ('', ''))
# Should we be flushing here?
cbegin, cend = LEVELNO_COLOR_CODES.get(record.levelno, ('', ''))
self._echofile.write(f'{cbegin}{msg}{cend}\n')
self._event_loop.call_soon_threadsafe(
tpartial(self._emit_in_loop, record.name, record.levelname,
tpartial(self._emit_in_loop, record.name, record.levelno,
record.created, msg))
def _emit_in_loop(self, name: str, levelname: str, created: float,
def _emit_in_loop(self, name: str, levelno: int, created: float,
message: str) -> None:
try:
self._emit_entry(
LogEntry(name=name,
message=message,
level=LOG_NAMES_TO_LEVELS.get(levelname,
LogLevel.INFO),
level=LEVELNO_LOG_LEVELS.get(levelno, LogLevel.INFO),
time=datetime.datetime.fromtimestamp(
created, datetime.timezone.utc)))
except Exception: