Platform agnostic logging
This commit is contained in:
@@ -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,12 +33,15 @@ import generate_config
|
|||||||
# LOGGING SETUP
|
# LOGGING SETUP
|
||||||
# ==============================================
|
# ==============================================
|
||||||
|
|
||||||
|
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 = 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(
|
||||||
'./logs/pterodisbot.log',
|
filename=os.path.join(logs_dir, 'pterodisbot.log'),
|
||||||
maxBytes=5*1024*1024, # 5 MiB max log file size
|
maxBytes=5*1024*1024, # 5 MiB max log file size
|
||||||
backupCount=3, # Rotate through 3 files
|
backupCount=3, # Rotate through 3 files
|
||||||
encoding='utf-8'
|
encoding='utf-8'
|
||||||
|
Reference in New Issue
Block a user