Configurable log level
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
@ -33,4 +34,5 @@ class Settings:
|
||||
board: BoardSettings
|
||||
inacivity_watchdog: InactivityWatchdogSettings
|
||||
ws_server: WSServerSettings
|
||||
log_level: int = logging.INFO
|
||||
debug: Optional[DebugSettings] = None
|
||||
|
||||
3
main.py
3
main.py
@ -4,9 +4,10 @@ from fastapi import FastAPI
|
||||
|
||||
from hopper.api.dependencies import create_game_engine
|
||||
from hopper.api.views import router
|
||||
from settings import settings
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
level=settings.log_level,
|
||||
format="%(asctime)s %(levelname)s - %(message)s",
|
||||
)
|
||||
logging.info("JFK Game server started.")
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import logging
|
||||
|
||||
from hopper.models.config import (
|
||||
BoardSettings,
|
||||
InactivityWatchdogSettings,
|
||||
@ -8,6 +10,7 @@ from hopper.models.config import (
|
||||
settings = Settings(
|
||||
board=BoardSettings(),
|
||||
inacivity_watchdog=InactivityWatchdogSettings(),
|
||||
log_level=logging.INFO,
|
||||
ws_server=WSServerSettings(),
|
||||
debug=None,
|
||||
)
|
||||
|
||||
@ -11,7 +11,7 @@ connected_clients = set[WebSocketServerProtocol]()
|
||||
|
||||
def setup_logging() -> None:
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
level=settings.log_level,
|
||||
format="%(asctime)s %(levelname)s - %(message)s",
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user