From: Sophie Brun <sophie@offensive-security.com>
Date: Fri, 4 Oct 2019 15:28:51 +0200
Subject: Change logs path

Last-Update: 2020-03-23
---
 app/logging/legionLog.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/app/logging/legionLog.py b/app/logging/legionLog.py
index eed8a1d..2cf3234 100644
--- a/app/logging/legionLog.py
+++ b/app/logging/legionLog.py
@@ -15,6 +15,7 @@ Copyright (c) 2020 GoVanguard
 
 Author(s): Dmitriy Dubson (d.dubson@gmail.com)
 """
+import os
 import logging
 from logging import Logger
 
@@ -22,24 +23,32 @@ cachedAppLogger = None
 cachedStartupLogger = None
 cachedDbLogger = None
 
+cache_path = os.path.expanduser("~/.cache/legion/log")
+log_path = os.path.join(cache_path, 'legion.log')
+if not os.path.isfile(log_path):
+    if not os.path.isdir(cache_path):
+        os.makedirs(cache_path)
 
 def getStartupLogger() -> Logger:
     global cachedStartupLogger
-    logger = getOrCreateCachedLogger("legion-startup", "./log/legion-startup.log", True, cachedStartupLogger)
+    logger = getOrCreateCachedLogger("legion-startup",
+            os.path.expanduser("~/.cache/legion/log/legion-startup.log"), True, cachedStartupLogger)
     cachedStartupLogger = logger
     return logger
 
 
 def getAppLogger() -> Logger:
     global cachedAppLogger
-    logger = getOrCreateCachedLogger("legion", "./log/legion.log", True, cachedAppLogger)
+    logger = getOrCreateCachedLogger("legion",
+            os.path.expanduser("~/.cache/legion/log/legion.log"), True, cachedAppLogger)
     cachedAppLogger = logger
     return logger
 
 
 def getDbLogger() -> Logger:
     global cachedDbLogger
-    logger = getOrCreateCachedLogger("legion-db", "./log/legion-db.log", False, cachedDbLogger)
+    logger = getOrCreateCachedLogger("legion-db",
+            os.path.expanduser("~/.cache/legion/log/legion-db.log"), False, cachedDbLogger)
     cachedDbLogger = logger
     return logger
 
