Skip to content

Commit

Permalink
Add util function for enable/disable SQL logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-jvessella committed Apr 29, 2024
1 parent 55a924f commit 92a031b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gamebrain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,14 @@ async def gamestate_get_is_team_active(
async def get_is_team_active(
team_id: str
) -> GenericResponse:
from util import enable_sql_logger, disable_sql_logger

enable_sql_logger()
active_teams = {
team["id"]
for team in await db.get_active_teams()
}
disable_sql_logger()
response = GenericResponse(
success=(team_id in active_teams),
message=team_id
Expand Down
12 changes: 12 additions & 0 deletions gamebrain/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,15 @@ async def cleanup_dead_sessions(nuke: bool = False):

async def nuke_active_sessions():
await cleanup_dead_sessions(True)


async def set_sql_logger(level):
logging.getLogger("sqlalchemy.engine").setLevel()


async def enable_sql_logger():
await set_sql_logger(logging.INFO)


async def disable_sql_logger():
await set_sql_logger(logging.NOTSET)

0 comments on commit 92a031b

Please sign in to comment.