# Released under the MIT License. See LICENSE for details.#"""Logging functionality."""from__future__importannotationsimportloggingfromenumimportEnumfromtypingimportTYPE_CHECKING,assert_neverfrombacommon.loggercontrolimportLoggerControlConfigifTYPE_CHECKING:pass# IMPORTANT: If making any changes here, be sure to update# binding_core.py and baenv.py where some of these same values are# hard-coded at engine init (when they don't yet have access to this# module).
[docs]classClientLoggerName(Enum):"""Logger names used on the Ballistica client."""BA='ba'ENV='ba.env'APP='ba.app'ASSETS='ba.assets'AUDIO='ba.audio'CACHE='ba.cache'DISPLAYTIME='ba.displaytime'GARBAGE_COLLECTION='ba.gc'GRAPHICS='ba.gfx'PERFORMANCE='ba.perf'INPUT='ba.input'LIFECYCLE='ba.lifecycle'NETWORKING='ba.net'CONNECTIVITY='ba.connectivity'V2TRANSPORT='ba.v2transport'CLOUD_SUBSCRIPTION='ba.cloudsub'ACCOUNT_CLIENT_V2='ba.accountclientv2'ACCOUNT_V2='ba.accountv2'LOGIN_ADAPTER='ba.loginadapter'@propertydefdescription(self)->str:"""Return a short description for the logger."""# pylint: disable=too-many-return-statements# pylint: disable=too-many-branchescls=type(self)ifselfiscls.BA:return'top level Ballistica logger - use to adjust everything'ifselfiscls.ENV:return'engine environment bootstrapping'ifselfiscls.APP:return'general app operation - INFO is visible by default'ifselfiscls.ASSETS:return'textures, sounds, models, etc.'ifselfiscls.AUDIO:return'sound and music playback'ifselfiscls.CACHE:return'cache dir - holds pycache, assets, etc.'ifselfiscls.DISPLAYTIME:return'timing for smooth animation display'ifselfiscls.GARBAGE_COLLECTION:return'garbage collection - debug memory leaks/etc.'ifselfiscls.GRAPHICS:return'anything graphics related'ifselfiscls.PERFORMANCE:return'debug rendering speed, hitches, etc.'ifselfiscls.INPUT:return'keyboards, touchscreens, game-controllers, etc.'ifselfiscls.LIFECYCLE:return'bootstrapping, pausing, resuming, shutdown, etc.'ifselfiscls.NETWORKING:return'anything network related'ifselfiscls.CONNECTIVITY:return'determining nearest/best regional servers'ifselfiscls.V2TRANSPORT:return'persistent connections to regional servers'ifselfiscls.CLOUD_SUBSCRIPTION:return'live values fed from regional server'ifselfiscls.ACCOUNT_CLIENT_V2:return'server communication for v2 accounts'ifselfiscls.ACCOUNT_V2:return'v2 (modern) account functionality'ifselfiscls.LOGIN_ADAPTER:return'support for particular login types'assert_never(self)
[docs]defget_base_logger_control_config_client()->LoggerControlConfig:"""Return the logger-control-config used by the Ballistica client. This should remain consistent since local logger configurations are stored relative to this. """# By default, go with WARNING on everything to keep things mostly# clean but show INFO for ba.app to get basic app startup messages# and whatnot.returnLoggerControlConfig(levels={'root':logging.WARNING,ClientLoggerName.APP.value:logging.INFO,})
# Docs-generation hack; import some stuff that we likely only forward-declared# in our actual source code so that docs tools can find it.fromtypingimport(Coroutine,Any,Literal,Callable,Generator,Awaitable,Sequence,Self)importasynciofromconcurrent.futuresimportFuturefrompathlibimportPathfromenumimportEnum