windows doesn't like the directories not existing

This commit is contained in:
michael-grace 2020-11-08 23:38:57 +00:00
parent 6fd34558e4
commit bdda886e10
2 changed files with 15 additions and 3 deletions

4
.gitignore vendored
View file

@ -3,7 +3,7 @@
__pycache__/
state/
state/*
*.egg-info/
@ -31,7 +31,7 @@ dev/welcome.mp3
build/build-exe-pyinstaller-command.sh
logs/
logs/*
*.mp3

View file

@ -1,5 +1,6 @@
import logging
from helpers.os_environment import resolve_external_file_path
import os
class LoggingManager():
@ -9,8 +10,19 @@ class LoggingManager():
def __init__(self, name):
self.logger = logging.getLogger(name)
filename: str = resolve_external_file_path("/logs/" + name + ".log")
if not os.path.isfile(filename):
try:
# Try creating the file.
open(filename, "x")
except Exception as e:
print(e)
print("Failed to create log file")
return
logging.basicConfig(
filename=resolve_external_file_path("/logs/" + name + ".log"),
filename=filename,
format='%(asctime)s | %(levelname)s | %(message)s',
level=logging.INFO,
filemode='a'