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