Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Add GH error logging to files
Browse files Browse the repository at this point in the history
  • Loading branch information
gingershaped committed Dec 18, 2023
1 parent dae30fe commit c6eaf07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vyxalbot2/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from time import time

import re
import json
import os
import traceback

from aiohttp import ClientSession
from aiohttp.web import Application, Request, Response
Expand Down Expand Up @@ -114,6 +117,14 @@ async def appToken(self) -> str:
return self._appToken.token
raise ValueError("Unable to locate installation")

def writeErrorReport(self, event: GitHubEvent, error: Exception):
os.makedirs("errorlogs/gh/", exist_ok=True)
with open(f"errorlogs/gh/{event.delivery_id}.txt") as file:
file.write(f"--- Error log for Github delivery {event.delivery_id}\n")
file.write("\n\n--- Traceback information:\n")
file.writelines(traceback.format_exception(error))
file.write("\n\n--- Delivery data:\n")
file.write(json.dumps(event.data, indent=4))
async def onHookRequest(self, request: Request) -> Response:
event = None
try:
Expand Down

0 comments on commit c6eaf07

Please sign in to comment.