From 8d26f5ce01972239b60619597493afba6409c729 Mon Sep 17 00:00:00 2001
From: anima
Date: Sun, 28 Nov 2021 18:18:40 +0100
Subject: [PATCH] add logging
---
main.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/main.py b/main.py
index 688bbd5..260d1d2 100644
--- a/main.py
+++ b/main.py
@@ -16,27 +16,39 @@
## Imports
import json
+import logging as log
from discord.ext import commands
from lib.keep_alive import keep_alive
## Vars
+### Load and set Bot Config
with open("bot.conf", 'r') as f:
BOTDATA = json.load(f)
bot = commands.Bot(command_prefix=BOTDATA['prefix'])
+### Set logging options
+log.basicConfig(
+ filename="bot.log",
+ level=log.DEBUG,
+ format='%(asctime)s - %(process)d-%(levelname)s: %(message)s',
+ datefmt='%Y-%m-%d %H:%M:%S'
+)
+
## Run
### Events
@bot.event
async def on_ready():
+ log.info(f'Logged in as {bot.user}')
print(f'Logged in as {bot.user}')
for guild in bot.guilds:
- print(f'Connect to Server {guild.name} (id: {guild.id})')
+ log.info(f'Connect to Server {guild.name} (id: {guild.id})')
### Commands
@bot.command(name='hello', help='Say hello!')
async def say_hello(ctx):
+ print(f'{ctx}')
await ctx.send(f'Hello, <@{ctx.author.id}>!')
print(ctx.guild)
print(ctx.message.content)