Skip to content

Commit

Permalink
feat: logger connect to app
Browse files Browse the repository at this point in the history
  • Loading branch information
avinogrado authored and the-homeless-god committed Aug 31, 2024
1 parent 7d7dcca commit 681202b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions application/backend/app/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import logging
import os


format = "%(asctime)s %(levelname)s: %(message)s"


def setupLoggerConfig(fileName):
logging.basicConfig(
level=logging.INFO,
format=format,
handlers=[
logging.FileHandler(os.getenv("LOG_FILE_PATH") + "logs/" + fileName),
logging.StreamHandler(),
],
)


def setupLogger():
setupLoggerConfig("info.log")
2 changes: 2 additions & 0 deletions application/backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from pathlib import Path
import os
import dotenv
from .logger import setupLogger
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

env = dotenv.load_dotenv()
setupLogger()
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

Expand Down

0 comments on commit 681202b

Please sign in to comment.