Skip to content

Commit

Permalink
Add exception logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DoomHammer committed Nov 5, 2023
1 parent d528686 commit 9c96f4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY *.py .
CMD ["python", "bot.py"]
CMD ["python", "bot.py", "--log=WARNING"]
11 changes: 7 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ async def on_ready():
"""
print(fields)
try:
os.makedirs(directory)
os.makedirs(directory, mode=0o777, exist_ok=True)
except FileExistsError:
pass
with open(f"{directory}/{filename}", "w") as f:
f.write(fields)
logging.exception("We can't create a tree. Why, oh why?")
try:
with open(f"{directory}/{filename}", "w") as f:
f.write(fields)
except PermissionError:
logging.exception("Oops, we can't write here!")
logging.info(
f"Guilds processed: {guilds_processed}, guilds total: {guilds_total}"
)
Expand Down

0 comments on commit 9c96f4f

Please sign in to comment.