windows doesn't like the directories not existing
This commit is contained in:
parent
6fd34558e4
commit
bdda886e10
2 changed files with 15 additions and 3 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
state/
|
state/*
|
||||||
|
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ dev/welcome.mp3
|
||||||
|
|
||||||
build/build-exe-pyinstaller-command.sh
|
build/build-exe-pyinstaller-command.sh
|
||||||
|
|
||||||
logs/
|
logs/*
|
||||||
|
|
||||||
*.mp3
|
*.mp3
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from helpers.os_environment import resolve_external_file_path
|
from helpers.os_environment import resolve_external_file_path
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class LoggingManager():
|
class LoggingManager():
|
||||||
|
@ -9,8 +10,19 @@ class LoggingManager():
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.logger = logging.getLogger(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(
|
logging.basicConfig(
|
||||||
filename=resolve_external_file_path("/logs/" + name + ".log"),
|
filename=filename,
|
||||||
format='%(asctime)s | %(levelname)s | %(message)s',
|
format='%(asctime)s | %(levelname)s | %(message)s',
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
filemode='a'
|
filemode='a'
|
||||||
|
|
Loading…
Reference in a new issue