Logging: add informative console logs for startup, ports, connections, JOIN/deny, input, and periodic events
- Configure logging via LOG_LEVEL env (default INFO) - Log when servers start listening (WT/QUIC/InMemory/HTTPS static) - Log WT CONNECT accept, QUIC peer connect, datagram traffic at DEBUG - Log GameServer creation, tick loop start, JOIN accept/deny, config_update broadcasts, and input reception
This commit is contained in:
7
run.py
7
run.py
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import os
|
||||
import logging
|
||||
|
||||
from server.server import GameServer
|
||||
from server.config import ServerConfig
|
||||
@@ -51,12 +52,18 @@ async def run_webtransport():
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
# Logging setup
|
||||
level = os.environ.get("LOG_LEVEL", "INFO").upper()
|
||||
logging.basicConfig(level=getattr(logging, level, logging.INFO), format="[%(asctime)s] %(levelname)s: %(message)s")
|
||||
mode = os.environ.get("MODE", "mem").lower()
|
||||
if mode == "wt":
|
||||
logging.info("Starting in WebTransport mode")
|
||||
asyncio.run(run_webtransport())
|
||||
elif mode == "quic":
|
||||
logging.info("Starting in QUIC datagram mode")
|
||||
asyncio.run(run_quic())
|
||||
else:
|
||||
logging.info("Starting in in-memory transport mode")
|
||||
asyncio.run(run_in_memory())
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user