Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
refine logging
Browse files Browse the repository at this point in the history
  • Loading branch information
CzBiX committed Sep 28, 2023
1 parent b9b9b9b commit 042bc43
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 0 additions & 4 deletions dev.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env python3

from sqlalchemy import log as sqlalchemy_log

sqlalchemy_log._add_default_handler = lambda x: None # Patch to avoid duplicate logging

def main():
from uvicorn import run

Expand Down
16 changes: 15 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ class Config:
env_file = '.env'
env_nested_delimiter = '__'

settings = Settings()
settings = Settings()

def init():
import logging

logging.basicConfig(level=logging.DEBUG if settings.debug else logging.INFO)

if settings.debug:
from sqlalchemy import log as sqlalchemy_log

# Patch to avoid duplicate sql echo
sqlalchemy_log._add_default_handler = lambda x: None


init()
2 changes: 0 additions & 2 deletions src/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from .purger import Purger
from .routers import subscription, sync, user, vault

logging.basicConfig(level=logging.DEBUG if settings.debug else logging.INFO)

logger = logging.getLogger(__name__)

@asynccontextmanager
Expand Down

0 comments on commit 042bc43

Please sign in to comment.