Skip to content

Commit 8ee3f61

Browse files
Liad-nLiad Noam
andauthored
Bugfix/logging system (#158)
* Changed logging config to be received by separate parameters for simplicity, removed option to receive configuration as a dict, added .vscode to gitignore * removed logging_config file which is no longer needed * Fixing merge conflicts - missing whitespace on config.py.example Co-authored-by: Liad Noam <LiadN@Taldor.corp>
1 parent b22fbdb commit 8ee3f61

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

app/dependencies.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from fastapi.templating import Jinja2Templates
55

66
from app import config
7+
from app.internal.logger_customizer import LoggerCustomizer
78

89

910
APP_PATH = os.path.dirname(os.path.realpath(__file__))
@@ -13,6 +14,14 @@
1314

1415
templates = Jinja2Templates(directory=TEMPLATES_PATH)
1516

17+
# Configure logger
18+
logger = LoggerCustomizer.make_logger(config.LOG_PATH,
19+
config.LOG_FILENAME,
20+
config.LOG_LEVEL,
21+
config.LOG_ROTATION_INTERVAL,
22+
config.LOG_RETENTION_INTERVAL,
23+
config.LOG_FORMAT)
24+
1625

1726
@lru_cache()
1827
def get_settings():

app/main.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
from app.database import models
77
from app.database.database import engine, get_db
88
from app.dependencies import (
9-
MEDIA_PATH, STATIC_PATH, templates)
9+
MEDIA_PATH, STATIC_PATH, templates, logger)
1010
from app.internal.quotes import load_quotes, daily_quotes
1111
from app.routers import (
1212
agenda, dayview, email, event, invitation, profile, search, telegram,
1313
whatsapp
1414
)
1515
from app.telegram.bot import telegram_bot
16-
from app.internal.logger_customizer import LoggerCustomizer
17-
from app import config
1816

1917

2018
def create_tables(engine, psql_environment):
@@ -35,14 +33,6 @@ def create_tables(engine, psql_environment):
3533

3634
load_quotes.load_daily_quotes(next(get_db()))
3735

38-
# Configure logger
39-
logger = LoggerCustomizer.make_logger(config.LOG_PATH,
40-
config.LOG_FILENAME,
41-
config.LOG_LEVEL,
42-
config.LOG_ROTATION_INTERVAL,
43-
config.LOG_RETENTION_INTERVAL,
44-
config.LOG_FORMAT)
45-
app.logger = logger
4636

4737
app.include_router(profile.router)
4838
app.include_router(event.router)
@@ -60,7 +50,7 @@ def create_tables(engine, psql_environment):
6050
# TODO: I add the quote day to the home page
6151
# until the relavent calendar view will be developed.
6252
@app.get("/")
63-
@app.logger.catch()
53+
@logger.catch()
6454
async def home(request: Request, db: Session = Depends(get_db)):
6555
quote = daily_quotes.quote_per_day(db)
6656
return templates.TemplateResponse("home.html", {

0 commit comments

Comments
 (0)