📝 Better logging
This commit is contained in:
@ -93,7 +93,7 @@ async def on_command_error(ctx, error):
|
||||
exception = exception[:index]
|
||||
|
||||
exceptionString = "".join(exception)
|
||||
logThis(f"exception in command !{ctx.command}, {exceptionString}",str(ctx.message.channel.id))
|
||||
logThis([f"exception in command !{ctx.command}", f"{exceptionString}"],str(ctx.message.channel.id), 40)
|
||||
await ctx.send("Something went wrong (error code 000)")
|
||||
|
||||
#Loads cogs
|
||||
|
@ -1,3 +1,4 @@
|
||||
from typing import Union
|
||||
import lxml.etree # Used by imageFunc
|
||||
import datetime # Used by helloFunc
|
||||
import json # Used by spellFunc
|
||||
@ -100,15 +101,22 @@ def imageFunc():
|
||||
logThis("Couldn't connect to bing (error code 701)")
|
||||
return(image)
|
||||
|
||||
def logThis(message : str, channel = ""):
|
||||
def logThis(messages : Union[str, list], channel = "", level = 20):
|
||||
localtime = time.asctime(time.localtime(time.time()))
|
||||
channel = channel.replace("Direct Message with ","")
|
||||
if channel == "":
|
||||
print(localtime+" - "+message)
|
||||
logging.info(localtime+" - "+message)
|
||||
else:
|
||||
print(localtime+" ("+channel+") - "+message)
|
||||
logging.info(localtime+" ("+channel+") - "+message)
|
||||
if type(messages) is str:
|
||||
messages = [messages]
|
||||
|
||||
for x, msg in enumerate(messages):
|
||||
if channel == "":
|
||||
messages[x] = localtime+" - "+msg
|
||||
else:
|
||||
messages[x] = localtime+" ("+channel+") - "+msg
|
||||
|
||||
print(messages[0])
|
||||
|
||||
for logMessage in messages:
|
||||
logging.log(level, logMessage)
|
||||
|
||||
# Finds a page from the Senkulpa Wikia
|
||||
def findWikiPage(search : str):
|
||||
|
Reference in New Issue
Block a user