Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b9d44a9
first logging commit
Jan 19, 2021
87ff7bc
took main from develop logging commit
Jan 19, 2021
0299b10
Added docstring and annotations to logger, added logger tests
Jan 21, 2021
1408056
Added docstring and annotations to logger, added logger tests
Jan 21, 2021
3cd2e37
Removed merge conflicts
Jan 21, 2021
c644bc0
Fixed an issue with variable name
Jan 21, 2021
ea9c0f4
Fixed requirements.txt duplicate rows.
Jan 21, 2021
c1e0221
Fixed requirements.txt duplicate rows, again.
Jan 21, 2021
5f14fc6
Fixed merge suggestions in logger_customizer.py
Jan 22, 2021
41febf5
Fixed merge suggestions in logger_customizer.py
Jan 22, 2021
c07f18d
Fixed linting in test_logging, conftest and logger_customizer, still …
Jan 22, 2021
973b4fc
Took config from global config file,
Jan 22, 2021
8c07e19
Fixed tests, created new clientless logger fixture. Another fixture l…
Jan 23, 2021
551936d
Updated conftest and separated logger fixtures to new file, fix mergi…
Jan 23, 2021
310bd58
Fix requirements for merging from develop
Jan 23, 2021
e71328d
Finished logger_fixture, added logging config file to tests, added lo…
Jan 23, 2021
88713de
Added logger_fixture and config which werent added for some reason
Jan 23, 2021
91322d9
Changed logging config to be received by separate parameters for simp…
Jan 24, 2021
bca9c7c
removed logging_config file which is no longer needed
Jan 26, 2021
26f0a40
Fixing merge conflicts
Jan 27, 2021
1a7fd84
Fixing merge conflicts - missing whitespace on config.py.example
Jan 27, 2021
8d10b6a
Fixed logger, no longer taken from app.logger - now instantiated in d…
Jan 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fastapi.templating import Jinja2Templates

from app import config
from app.internal.logger_customizer import LoggerCustomizer


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

templates = Jinja2Templates(directory=TEMPLATES_PATH)

# Configure logger
logger = LoggerCustomizer.make_logger(config.LOG_PATH,
config.LOG_FILENAME,
config.LOG_LEVEL,
config.LOG_ROTATION_INTERVAL,
config.LOG_RETENTION_INTERVAL,
config.LOG_FORMAT)


@lru_cache()
def get_settings():
Expand Down
14 changes: 2 additions & 12 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
from app.database import models
from app.database.database import engine, get_db
from app.dependencies import (
MEDIA_PATH, STATIC_PATH, templates)
MEDIA_PATH, STATIC_PATH, templates, logger)
from app.internal.quotes import load_quotes, daily_quotes
from app.routers import (
agenda, dayview, email, event, invitation, profile, search, telegram,
whatsapp
)
from app.telegram.bot import telegram_bot
from app.internal.logger_customizer import LoggerCustomizer
from app import config


def create_tables(engine, psql_environment):
Expand All @@ -35,14 +33,6 @@ def create_tables(engine, psql_environment):

load_quotes.load_daily_quotes(next(get_db()))

# Configure logger
logger = LoggerCustomizer.make_logger(config.LOG_PATH,
config.LOG_FILENAME,
config.LOG_LEVEL,
config.LOG_ROTATION_INTERVAL,
config.LOG_RETENTION_INTERVAL,
config.LOG_FORMAT)
app.logger = logger

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