Save logs in a directory

This commit is contained in:
oldnapalm
2020-11-19 08:45:37 -03:00
committed by GitHub
parent 0b9c4aefac
commit a6dbf1fbdf
+8 -1
View File
@@ -82,8 +82,15 @@ SECRET_KEY_FILE = "%s/secret-key.txt" % STORAGE_DIR
MULTIPLAYER = False
if os.path.exists("%s/multiplayer.txt" % STORAGE_DIR):
MULTIPLAYER = True
LOGS_DIR = "%s/logs" % SCRIPT_DIR
try:
if not os.path.isdir(LOGS_DIR):
os.makedirs(LOGS_DIR)
except IOError as e:
logger.error("failed to create logs dir (%s): %s", LOGS_DIR, str(e))
sys.exit(1)
from logging.handlers import RotatingFileHandler
logHandler = RotatingFileHandler('zoffline.log', maxBytes=1000000, backupCount=10)
logHandler = RotatingFileHandler('%s/zoffline.log' % LOGS_DIR, maxBytes=1000000, backupCount=10)
logger.addHandler(logHandler)
from tokens import *