Skip to content

Instantly share code, notes, and snippets.

@MirasSafadi
MirasSafadi / settings.py
Last active April 7, 2025 08:56
Using secrets in a Python app
import os
from dotenv import load_dotenv
import constants
load_dotenv()
DB_USERNAME = os.getenv(constants.DB_USERNAME)
DB_PASSWORD = os.getenv(constants.DB_PASSWORD)
IS_DEBUG = os.getenv(constants.IS_DEBUG, constants.FALSE).lower() == constants.TRUE.lower()
@MirasSafadi
MirasSafadi / logger.py
Last active April 8, 2025 10:31
Generic Python Logger
import logging
from logging.handlers import RotatingFileHandler
import settings
debug = settings.IS_DEBUG
class Logger:
def __init__(self,module):
self.module = module
self.logger = logging.getLogger(module)
self.level = logging.DEBUG if debug else logging.INFO