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 | 14 +++++++++++++-
 db/database.py           | 13 ++++++++++++-
 legion.py                | 13 ++++++++++++-
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/app/logging/legionLog.py b/app/logging/legionLog.py
index da3ee51..407a0d6 100644
--- a/app/logging/legionLog.py
+++ b/app/logging/legionLog.py
@@ -15,9 +15,21 @@ Copyright (c) 2020 GoVanguard
 
 Author(s): Dmitriy Dubson (d.dubson@gmail.com)
 """
+import os
 import logging
+from shutil import copyfile
 
 from utilities.stenoLogging import get_logger
 
-log = get_logger('legion', path="./log/legion.log", console=False)
+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)
+#    if os.path.isfile('./log/legion.log'):
+#        copyfile('./log/legion.log', log_path)
+#    else:
+#        log_path = './log/legion.log'
+
+log = get_logger('legion', path=log_path, console=False)
 log.setLevel(logging.INFO)
diff --git a/db/database.py b/db/database.py
index c62ed3c..fd975a2 100644
--- a/db/database.py
+++ b/db/database.py
@@ -16,7 +16,18 @@ Copyright (c) 2020 GoVanguard
 """
 from utilities.stenoLogging import *
 
-log = get_logger('legion', path="./log/legion-db.log", console=False)
+import os
+from shutil import copyfile
+
+from utilities.stenoLogging import *
+
+cache_path = os.path.expanduser("~/.cache/legion/log")
+log_path = os.path.join(cache_path, 'legion-db.log')
+if not os.path.isfile(log_path):
+    if not os.path.isdir(cache_path):
+        os.makedirs(cache_path)
+    copyfile('./log/legion-db.log', log_path)
+log = get_logger('legion', path=log_path, console=False)
 log.setLevel(logging.INFO)
 
 from PyQt5.QtCore import QSemaphore
diff --git a/legion.py b/legion.py
index dbe924c..532cc36 100644
--- a/legion.py
+++ b/legion.py
@@ -22,7 +22,18 @@ from ui.eventfilter import MyEventFilter
 from ui.ViewState import ViewState
 from utilities.stenoLogging import *
 
-log = get_logger('legion', path="./log/legion-startup.log")
+import os
+from shutil import copyfile
+
+from utilities.stenoLogging import *
+
+cache_path = os.path.expanduser("~/.cache/legion/log")
+log_path = os.path.join(cache_path, 'legion-startup.log')
+if not os.path.isfile(log_path):
+    if not os.path.isdir(cache_path):
+        os.makedirs(cache_path)
+    copyfile('./log/legion-startup.log', log_path)
+log = get_logger('legion', path=log_path)
 log.setLevel(logging.INFO)
 
 # check for dependencies first (make sure all non-standard dependencies are checked for here)
