Ensure paths work on *Nix & Windows

pull/2/head
sgoudham 3 years ago
parent 45f28560c9
commit cb2f6866dd
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -1,5 +1,6 @@
import logging import logging
import os import os
from pathlib import Path
from dotenv import load_dotenv from dotenv import load_dotenv
@ -9,10 +10,14 @@ load_dotenv()
# Constants # Constants
BOT_TOKEN = os.environ.get("BOT_TOKEN") BOT_TOKEN = os.environ.get("BOT_TOKEN")
BOT_PREFIX = "!" BOT_PREFIX = "!"
DB_FILE = Path("db", "charity.db")
DB_FILE.parent.mkdir(parents=True, exist_ok=True)
LOG_FILE = Path("logs", "discord.log")
LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
# Set Up Logging # Set Up Logging
logger = logging.getLogger('discord') LOGGER = logging.getLogger("discord")
logger.setLevel(logging.DEBUG) LOGGER.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w') handler = logging.FileHandler(filename=LOG_FILE, encoding="utf-8", mode="w")
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
logger.addHandler(handler) LOGGER.addHandler(handler)

Loading…
Cancel
Save