Skip to content

Commit

Permalink
Merge pull request #318 from poettler-ric/fix-logging
Browse files Browse the repository at this point in the history
Fix logging
  • Loading branch information
blitzmann committed Jul 8, 2015
2 parents 5ac3192 + f08dc97 commit 5baf706
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
saveDB = None
gameDB = None

def __createSavePath():
if not os.path.exists(savePath):
os.mkdir(savePath)

def defPaths():
global pyfaPath
global savePath
Expand Down Expand Up @@ -59,6 +63,7 @@ def defPaths():

format = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
logging.basicConfig(format=format, level=logLevel)
__createSavePath()
handler = logging.handlers.RotatingFileHandler(os.path.join(savePath, "log.txt"), maxBytes=1000000, backupCount=3)
formatter = logging.Formatter(format)
handler.setFormatter(formatter)
Expand All @@ -69,15 +74,13 @@ def defPaths():
# Redirect stderr to file if we're requested to do so
stderrToFile = getattr(configforced, "stderrToFile", None)
if stderrToFile is True:
if not os.path.exists(savePath):
os.mkdir(savePath)
__createSavePath()
sys.stderr = open(os.path.join(savePath, "error_log.txt"), "w")

# Same for stdout
stdoutToFile = getattr(configforced, "stdoutToFile", None)
if stdoutToFile is True:
if not os.path.exists(savePath):
os.mkdir(savePath)
__createSavePath()
sys.stdout = open(os.path.join(savePath, "output_log.txt"), "w")

# Static EVE Data from the staticdata repository, should be in the staticdata
Expand Down

0 comments on commit 5baf706

Please sign in to comment.