mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-26 17:03:14 +08:00
logging output to sys.stderr is now immediate instead of deferred in bg thread
This commit is contained in:
parent
cfe42b39e6
commit
6cfcab8e97
@ -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/9a/b0/687077bb5518ba6297514a21cf79",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/9a/07/a28a396bd3aff9c7d8ea4425c972",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/98/86/2b057bf3acb6707ee2345ae48726",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/13/96/49d0b9a8a5a808a619318e4ed3bd",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ed/87/b71085642185d3150a3dd59ed593",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/62/9b/2b1d5dbfa88a3b71c1476940ded0",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/b7/12/f1f6253a38af6278dbcc4ee13345",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c7/79/dc992d142c303287a321d22a51c9",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/8a/90/9e476b436c7f9211f2e49308a063",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/a8/9c/090dbf15aeb803532b96093ffb2e",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e3/2c/0eb229b654494a9bb99a663bee34",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ff/94/996c258446bcd1587ce55814c10f",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ac/d9/8baaae8352bcd21034d5daea284c",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7f/f3/2d78f72daebb218658f4dc010e8e",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/75/5e/a887e7a232caed9a4a0a9a0909ae",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/30/0d/f0de21829b62bf1256781df266ed",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/8d/10/a54cfe97f26717ab57477860cb43",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/14/30/350f4c8f8b17326c161a05353afa",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/ab/43/79fd942d5e2f99f49726d15fbebd",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/50/fc/8ac0aa34cc5e792dd126a96deb7f",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c6/ea/046da6628c165fc2f57754486fd9",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b0/fc/a8e896f1f000b21d5cb53d402e04",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/63/8a/8d16dabe1e1cc65b79eb9193faee",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ba/48/f856c0d0a900b7342b0bdc62ae9e",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/1f/57/2e720d8a0dd11809ec104ec9ecab",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/a9/d5/bd6e5ca106e8a90262bc8b9dcd60",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1a/3f/8d5e5bd44674ff7a1c1454ad098c",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/11/8b/2bab6adadbf26d312159050ba841",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/86/28/0a2a0560e7d2e756baaeeed1915a",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/dd/5e/9e50b09abfabd164468dfcdf2308",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/87/13/b5b8f50c337edb45488fce4cb1f6",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/43/52/1ad22b14b05e5d47608d90764a6e",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/68/e1/c85510e3f00de73a62fc45a6055b",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/d3/60/d9d4ff50d2dc680f01ffc64f8e49",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/64/eb/5f0a49d9c18084cd364986fddadb",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8c/be/dc1ac45e83fadb21f1e2be223808",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/dd/30/9cc3c63c1e097ce28fa26698f83d",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/84/6d/159447f3d28ccfd80e747f295c9b",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/58/07/c3250bdc3825247bb2db06f4fadf",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/8e/d9/6bafcc87a2ce6749abf5de8300aa",
|
||||
"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",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
### 1.7.7 (build 20849, api 7, 2022-09-14)
|
||||
### 1.7.7 (build 20851, api 7, 2022-09-14)
|
||||
- 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.
|
||||
|
||||
@ -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 = 20849
|
||||
expected_build = 20851
|
||||
running_build: int = env['build_number']
|
||||
if running_build != expected_build:
|
||||
print(
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
namespace ballistica {
|
||||
|
||||
// These are set automatically via script; don't modify them here.
|
||||
const int kAppBuildNumber = 20849;
|
||||
const int kAppBuildNumber = 20851;
|
||||
const char* kAppVersion = "1.7.7";
|
||||
|
||||
// Our standalone globals.
|
||||
|
||||
@ -45,6 +45,16 @@ LOG_NAMES_TO_LEVELS = {
|
||||
'CRITICAL': LogLevel.CRITICAL
|
||||
}
|
||||
|
||||
LOG_LEVEL_NUMS_TO_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),
|
||||
logging.ERROR: (TerminalColor.RED.value, TerminalColor.RESET.value),
|
||||
logging.CRITICAL:
|
||||
(TerminalColor.STRONG_MAGENTA.value + TerminalColor.BOLD.value +
|
||||
TerminalColor.BG_BLACK.value, TerminalColor.RESET.value),
|
||||
}
|
||||
|
||||
|
||||
@ioprepped
|
||||
@dataclass
|
||||
@ -133,6 +143,19 @@ class LogHandler(logging.Handler):
|
||||
# didn't expect to be stringified.
|
||||
msg = self.format(record)
|
||||
|
||||
# Also print pretty colored output to our echo file (generally
|
||||
# stderr). We do this part here instead of in our bg thread
|
||||
# because the delay can throw off command line prompts or make
|
||||
# tight debugging harder.
|
||||
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?
|
||||
self._echofile.write(f'{cbegin}{msg}{cend}\n')
|
||||
|
||||
self._event_loop.call_soon_threadsafe(
|
||||
tpartial(self._emit_in_loop, record.name, record.levelname,
|
||||
record.created, msg))
|
||||
@ -223,31 +246,6 @@ class LogHandler(logging.Handler):
|
||||
assert '\n' not in entry_s # Make sure its a single line.
|
||||
print(entry_s, file=self._file, flush=True)
|
||||
|
||||
# Also print pretty colored output to our echo file (stdout/stderr).
|
||||
# Note that we don't do this for log entries generated from
|
||||
# stdout/stderr since that would result in them being printed
|
||||
# twice.
|
||||
if (self._echofile is not None
|
||||
and entry.name not in ('stdout', 'stderr')):
|
||||
cbegin: str
|
||||
cend: str
|
||||
cbegin, cend = {
|
||||
LogLevel.DEBUG:
|
||||
(TerminalColor.CYAN.value, TerminalColor.RESET.value),
|
||||
LogLevel.INFO: ('', ''),
|
||||
LogLevel.WARNING:
|
||||
(TerminalColor.YELLOW.value, TerminalColor.RESET.value),
|
||||
LogLevel.ERROR:
|
||||
(TerminalColor.RED.value, TerminalColor.RESET.value),
|
||||
LogLevel.CRITICAL:
|
||||
(TerminalColor.STRONG_MAGENTA.value +
|
||||
TerminalColor.BOLD.value + TerminalColor.BG_BLACK.value,
|
||||
TerminalColor.RESET.value),
|
||||
}[entry.level]
|
||||
|
||||
# Should we be flushing here?
|
||||
self._echofile.write(f'{cbegin}{entry.message}{cend}\n')
|
||||
|
||||
|
||||
class FileLogEcho:
|
||||
"""A file-like object for forwarding stdout/stderr to a LogHandler."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user