mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-11-07 17:36:15 +00:00
configurable error logging
This commit is contained in:
parent
61e949f909
commit
72583e1ea9
1 changed files with 85 additions and 72 deletions
|
|
@ -16,6 +16,10 @@ from pathlib import Path
|
||||||
from threading import Lock, Thread, current_thread
|
from threading import Lock, Thread, current_thread
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from nbstreamreader import NonBlockingStreamReader as NBSR
|
from nbstreamreader import NonBlockingStreamReader as NBSR
|
||||||
|
|
||||||
|
ERROR_LOGGING=False
|
||||||
|
|
||||||
|
|
||||||
# We make use of the bacommon and efro packages as well as site-packages
|
# We make use of the bacommon and efro packages as well as site-packages
|
||||||
# included with our bundled Ballistica dist, so we need to add those paths
|
# included with our bundled Ballistica dist, so we need to add those paths
|
||||||
# before we import them.
|
# before we import them.
|
||||||
|
|
@ -36,6 +40,7 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
VERSION_STR = '1.3'
|
VERSION_STR = '1.3'
|
||||||
|
|
||||||
|
|
||||||
# Version history:
|
# Version history:
|
||||||
# 1.3.1
|
# 1.3.1
|
||||||
# Windows binary is now named BallisticaCoreHeadless.exe
|
# Windows binary is now named BallisticaCoreHeadless.exe
|
||||||
|
|
@ -584,8 +589,7 @@ class ServerManagerApp:
|
||||||
|
|
||||||
# Launch!
|
# Launch!
|
||||||
try:
|
try:
|
||||||
|
if ERROR_LOGGING:
|
||||||
|
|
||||||
self._subprocess = subprocess.Popen(
|
self._subprocess = subprocess.Popen(
|
||||||
[binary_name, '-cfgdir', self._ba_root_path],
|
[binary_name, '-cfgdir', self._ba_root_path],
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
|
@ -595,6 +599,12 @@ class ServerManagerApp:
|
||||||
|
|
||||||
self.nbsr = NBSR(self._subprocess.stdout)
|
self.nbsr = NBSR(self._subprocess.stdout)
|
||||||
self.nbsrerr = NBSR(self._subprocess.stderr)
|
self.nbsrerr = NBSR(self._subprocess.stderr)
|
||||||
|
else:
|
||||||
|
self._subprocess = subprocess.Popen(
|
||||||
|
[binary_name, '-cfgdir', self._ba_root_path],
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
cwd='dist')
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self._subprocess_exited_cleanly = False
|
self._subprocess_exited_cleanly = False
|
||||||
print(
|
print(
|
||||||
|
|
@ -724,6 +734,7 @@ class ServerManagerApp:
|
||||||
break
|
break
|
||||||
# output=self._subprocess.stdout.readline()
|
# output=self._subprocess.stdout.readline()
|
||||||
# print(output)
|
# print(output)
|
||||||
|
if ERROR_LOGGING:
|
||||||
out = self.nbsr.readline(0.1)
|
out = self.nbsr.readline(0.1)
|
||||||
out2 = self.nbsrerr.readline(0.1)
|
out2 = self.nbsrerr.readline(0.1)
|
||||||
if out:
|
if out:
|
||||||
|
|
@ -763,7 +774,6 @@ class ServerManagerApp:
|
||||||
# Watch for the server process exiting..
|
# Watch for the server process exiting..
|
||||||
code: Optional[int] = self._subprocess.poll()
|
code: Optional[int] = self._subprocess.poll()
|
||||||
if code is not None:
|
if code is not None:
|
||||||
|
|
||||||
clr = Clr.CYN if code == 0 else Clr.RED
|
clr = Clr.CYN if code == 0 else Clr.RED
|
||||||
print(
|
print(
|
||||||
f'{clr}Server subprocess exited'
|
f'{clr}Server subprocess exited'
|
||||||
|
|
@ -883,6 +893,8 @@ def main() -> None:
|
||||||
# Any others will bubble up and give us the usual mess.
|
# Any others will bubble up and give us the usual mess.
|
||||||
exc.pretty_print()
|
exc.pretty_print()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def dump_logs(msg):
|
def dump_logs(msg):
|
||||||
if os.path.isfile('logs.log'):
|
if os.path.isfile('logs.log'):
|
||||||
size = os.path.getsize('logs.log')
|
size = os.path.getsize('logs.log')
|
||||||
|
|
@ -893,5 +905,6 @@ def dump_logs(msg):
|
||||||
with open("logs.log", "a") as f:
|
with open("logs.log", "a") as f:
|
||||||
f.write(msg)
|
f.write(msg)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue