Add dynamic log directory
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -174,7 +174,8 @@ cython_debug/
|
|||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
|
|
||||||
# Other files
|
# Logs
|
||||||
|
/logs
|
||||||
|
|
||||||
|
# Config file
|
||||||
config.ini
|
config.ini
|
||||||
*.log
|
|
||||||
*.log.*
|
|
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"401095ca": {
|
"401095ca": {
|
||||||
"channel_id": "1392730642206429307",
|
"channel_id": "1392730642206429307",
|
||||||
"message_id": "1396377026000322712"
|
"message_id": "1404091156421279935"
|
||||||
},
|
},
|
||||||
"548c4f18": {
|
"548c4f18": {
|
||||||
"channel_id": "1392730682576343121",
|
"channel_id": "1392730682576343121",
|
||||||
"message_id": "1396377032589447258"
|
"message_id": "1404091162607747135"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -16,6 +16,7 @@ Features:
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
import os
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
@@ -32,14 +33,17 @@ import generate_config
|
|||||||
# LOGGING SETUP
|
# LOGGING SETUP
|
||||||
# ==============================================
|
# ==============================================
|
||||||
|
|
||||||
logger = logging.getLogger('pterodactyl_bot')
|
logs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logs')
|
||||||
|
os.makedirs(logs_dir, exist_ok=True)
|
||||||
|
|
||||||
|
logger = logging.getLogger('pterodisbot')
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
# File handler for logs (rotates when reaching 5MB, keeps 3 backups)
|
# File handler for logs (rotates when reaching 5MB, keeps 3 backups)
|
||||||
handler = RotatingFileHandler(
|
handler = RotatingFileHandler(
|
||||||
'pterodactyl_bot.log',
|
filename=os.path.join(logs_dir, 'pterodisbot.log'),
|
||||||
maxBytes=5*1024*1024,
|
maxBytes=5*1024*1024, # 5 MiB max log file size
|
||||||
backupCount=3,
|
backupCount=3, # Rotate through 3 files
|
||||||
encoding='utf-8'
|
encoding='utf-8'
|
||||||
)
|
)
|
||||||
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
|
handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
|
||||||
|
Reference in New Issue
Block a user