-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
94 lines (87 loc) · 2.57 KB
/
settings.py
File metadata and controls
94 lines (87 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os
import logging
from colorlog import ColoredFormatter
from dotenv import load_dotenv
from logging.config import dictConfig
import pathlib
load_dotenv()
# Accessing the environment variables
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
COMMAND_PREFIX = os.getenv('COMMAND_PREFIX')
EMBED_COLOR = int(os.getenv('EMBED_COLOR'), 16)
FEEDBACK_CHANNEL_ID = int(os.getenv('FEEDBACK_CHANNEL_ID'))
# Database
DATABASE_NAME = os.getenv('DATABASE_NAME')
DATABASE_USER = os.getenv('DATABASE_USER')
DATABASE_PASSWORD = os.getenv('DATABASE_PASSWORD')
DATABASE_HOST = os.getenv('DATABASE_HOST')
DATABASE_PORT = os.getenv('DATABASE_PORT')
# Define directories
BASE_DIR = pathlib.Path(__file__).parent
COGS_DIR = BASE_DIR / 'cogs'
# Make sure ./logs directory exists
if not os.path.exists('logs'):
os.makedirs('logs')
# Logging configuration
LOGGING_CONFIG = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
# Add a verbose formatter for debugging with more information
"verbose": {
"format": "%(levelname)-10s - %(asctime)s - %(module)-15s : %(message)s",
},
# Define the default formatter
'default': {
'()': 'colorlog.ColoredFormatter',
'format': "%(log_color)s%(levelname)-10s - %(name)-15s : %(message)s",
'log_colors': {
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red,bg_white',
},
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'default',
},
'file_bot': {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': 'logs/bot.log',
'mode': 'w',
},
'file_user': {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': 'logs/user.log',
'mode': 'w',
},
},
'loggers': {
'bot': {
'handlers': ['console', 'file_user'],
'level': 'INFO',
},
'disnake': {
'handlers': ['console', 'file_bot'],
'level': 'INFO',
},
'database': {
'handlers': ['console', 'file_bot'],
'level': 'INFO',
},
'commands': {
'handlers': ['console', 'file_user'],
'level': 'INFO',
},
},
}
dictConfig(LOGGING_CONFIG)