every-Bot / everyBot

A discordpy bot for all purposes
GNU Lesser General Public License v3.0
4 stars 3 forks source link

Implement basic logging function #30

Open JBrummans opened 3 years ago

JBrummans commented 3 years ago

The bot should log every command someone runs for troubleshooting and monitoring purposes.

EG using pythons build in logging function should work:

import logging

logging.basicConfig(filename=os.getenv("LOG_FILE"), level=logging.INFO, filemode='a', format='%(asctime)s - %(levelname)s - %(message)s')

@bot.before_invoke
async def command_logger(ctx):
  server = ctx.guild.name
  logging.info(str(server) + ":" + str(ctx.author) + " ran the command "+ bot.command_prefix + str(ctx.command))