add log.py and set logger handlers correctly in all files.

This commit is contained in:
2021-08-11 20:02:47 +02:00
parent 6e5d8261ff
commit 2d69abbd37
8 changed files with 67 additions and 56 deletions

View File

@@ -1,10 +1,11 @@
import discord
from discord.ext import commands
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
embed = discord.Embed()
@@ -20,12 +21,12 @@ class Admin(commands.Cog):
@commands.is_owner()
async def clear(self, ctx, amount=1):
await ctx.channel.purge(limit=amount)
logger.warn(f'{ctx.message.author.name} cleared {amount} messages')
log.warn(f'{ctx.message.author.name} cleared {amount} messages')
@commands.Cog.listener()
async def on_ready(self):
print('##### ADMIN module active')
log.info(f'module active')
def setup(bot):

View File

@@ -2,11 +2,11 @@ import discord
from discord.ext import commands
import logging
from jeevesbot import functions, babbelbingo
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
e = discord.Embed()
@@ -27,7 +27,7 @@ class Games(commands.Cog):
roll,result = functions.roll(param)
msg = f'Rolling %s for {ctx.message.author.mention}: `%s`'.format(roll) % (param,roll)
logline = f'Rolling %s for {ctx.message.author}: `%s`'.format(roll) % (param,roll)
logger.info(logline)
log.info(logline)
await ctx.send(msg)
@@ -41,7 +41,7 @@ class Games(commands.Cog):
@commands.Cog.listener()
async def on_ready(self):
print('##### GAMES module active')
log.info(f'module active')
def setup(bot):

View File

@@ -2,11 +2,11 @@ import discord
from discord.ext import commands
import logging
from jeevesbot import functions
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
e = discord.Embed()
@@ -33,7 +33,7 @@ class Gif(commands.Cog):
if roles is not True:
await message.channel.send(embed=embed)
logline = (str(message.author) + ' requested a gif: ' + str(gif_url))
logger.info(logline)
log.info(logline)
if message.content.endswith('.gif'):
roles = functions.checkrole(message.author.roles)
channel = functions.checkchannel(message.channel.id)
@@ -43,7 +43,7 @@ class Gif(commands.Cog):
if roles is not True:
await message.channel.send(embed=embed)
logline = (str(message.author) + ' requested a gif: ' + str(embed_url))
logger.info(logline)
log.info(logline)
if message.content.startswith('https://giphy.com/'):
roles = functions.checkrole(message.author.roles)
channel = functions.checkchannel(message.channel.id)
@@ -55,12 +55,12 @@ class Gif(commands.Cog):
if roles is not True:
await message.channel.send(embed=embed)
logline = (str(message.author) + ' requested a gif: ' + str(gif_url))
logger.info(logline)
log.info(logline)
@commands.Cog.listener()
async def on_ready(self):
print('##### GIF module active')
log.info(f'module active')
def setup(bot):

View File

@@ -1,10 +1,10 @@
import discord
from discord.ext import commands
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
e = discord.Embed()
@@ -29,7 +29,7 @@ class Links(commands.Cog):
@commands.Cog.listener()
async def on_ready(self):
print('##### LINKS module active')
log.info(f'module active')
def setup(bot):

View File

@@ -1,10 +1,10 @@
import discord
from discord.ext import commands
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
e = discord.Embed()
@@ -30,7 +30,7 @@ class Misc(commands.Cog):
@commands.Cog.listener()
async def on_ready(self):
print('##### RANDOM module active')
log.info(f'module active')
def setup(bot):

View File

@@ -1,10 +1,10 @@
import discord
from discord.ext import commands
import log
from logging import getLogger
# setup logging
logger = log.get_logger(__name__)
log = getLogger(__name__)
e = discord.Embed()
@@ -19,8 +19,8 @@ class Moderator(commands.Cog):
@commands.Cog.listener()
async def on_ready(self):
print('##### MODERATOR module active')
log.info(f'module active')
def setup(bot):
bot.add_cog(Moderator(bot))