From 8bf93fa03873326d675240e49e2c90fcb8aa3428 Mon Sep 17 00:00:00 2001 From: Stephen Dade Date: Wed, 11 Sep 2024 20:10:19 +1000 Subject: [PATCH 1/3] Configuration: use correct case for filesystem section in config yaml --- FreeTAKServer/core/configuration/MainConfig.py | 3 ++- .../core/configuration/configuration_wizard.py | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/FreeTAKServer/core/configuration/MainConfig.py b/FreeTAKServer/core/configuration/MainConfig.py index 3bb55383..ea0e2a85 100644 --- a/FreeTAKServer/core/configuration/MainConfig.py +++ b/FreeTAKServer/core/configuration/MainConfig.py @@ -436,7 +436,8 @@ def validate_and_sanitize_path(self, path): sanitized_path = ROOTPATH + os.path.relpath(os.path.normpath(os.path.join(os.sep, path)), os.sep) if not os.access(sanitized_path, os.F_OK) or not os.access(sanitized_path, os.W_OK): - raise ValueError + print(f"Cannot access configuration path: {sanitized_path}") + sys.exit(1) return sanitized_path diff --git a/FreeTAKServer/core/configuration/configuration_wizard.py b/FreeTAKServer/core/configuration/configuration_wizard.py index 64b03ef7..8517abcf 100644 --- a/FreeTAKServer/core/configuration/configuration_wizard.py +++ b/FreeTAKServer/core/configuration/configuration_wizard.py @@ -85,7 +85,7 @@ def ask_user_for_config(): else: print('invalid database type') config.DBFilePath = database_path - add_to_config(data=database_path, path=["FileSystem", "FTS_DB_PATH"], source=yaml_config) + add_to_config(data=database_path, path=["Filesystem", "FTS_DB_PATH"], source=yaml_config) main_path = get_user_input(question="enter the preferred main path", default=config.MainPath) while not valid_and_safe_path(main_path): @@ -93,14 +93,14 @@ def ask_user_for_config(): main_path = get_user_input(question="enter the preferred main path", default=config.MainPath) config.MainPath = main_path - add_to_config(path=["FileSystem", "FTS_MAINPATH"], data= main_path, source= yaml_config) + add_to_config(path=["Filesystem", "FTS_MAINPATH"], data= main_path, source= yaml_config) log_path = get_user_input(question="enter the preferred log file path", default=config.LogFilePath) while not valid_and_safe_path(log_path): print("Invalid path. Path does not exist or insufficient permissions exist.") log_path = get_user_input(question="enter the preferred log file path", default=config.LogFilePath) - add_to_config(path=["FileSystem", "FTS_LOGFILE_PATH"], data=log_path, source=yaml_config) + add_to_config(path=["Filesystem", "FTS_LOGFILE_PATH"], data=log_path, source=yaml_config) add_to_config(path=["System", "FTS_NODE_ID"], data=config.nodeID, source=yaml_config) @@ -156,9 +156,9 @@ def autogenerate_config(): add_to_config(data=config.UserConnectionIP, path=["Addresses", "FTS_DP_ADDRESS"], source=yaml_config) add_to_config(data=config.UserConnectionIP, path=["Addresses", "FTS_USER_ADDRESS"], source=yaml_config) - add_to_config(data=config.DBFilePath, path=["FileSystem", "FTS_DB_PATH"], source=yaml_config) - add_to_config(path=["FileSystem", "FTS_MAINPATH"], data=config.MainPath, source=yaml_config) - add_to_config(path=["FileSystem", "FTS_LOGFILE_PATH"], data=config.LogFilePath, source=yaml_config) + add_to_config(data=config.DBFilePath, path=["Filesystem", "FTS_DB_PATH"], source=yaml_config) + add_to_config(path=["Filesystem", "FTS_MAINPATH"], data=config.MainPath, source=yaml_config) + add_to_config(path=["Filesystem", "FTS_LOGFILE_PATH"], data=config.LogFilePath, source=yaml_config) add_to_config(path=["System", "FTS_NODE_ID"], data=config.nodeID, source=yaml_config) file = open(config.yaml_path, mode="w+") @@ -185,7 +185,7 @@ def autogenerate_config(): #FTS_API_PORT: 19023 #FTS_FED_PORT: 9000 #FTS_API_ADDRESS: 0.0.0.0 -FileSystem: +Filesystem: FTS_DB_PATH: /opt/fts/FreeTAKServer.db #FTS_COT_TO_DB: True FTS_PERSISTENCE_PATH: /opt/fts/ From 9da07f66af35834ed07b4a1e1b3f299c39f07ecd Mon Sep 17 00:00:00 2001 From: Stephen Dade Date: Wed, 11 Sep 2024 20:41:10 +1000 Subject: [PATCH 2/3] Logging: Make log folder consistent --- .../CreateStartupFilesController.py | 2 +- .../core/configuration/LoggingConstants.py | 27 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/FreeTAKServer/core/configuration/CreateStartupFilesController.py b/FreeTAKServer/core/configuration/CreateStartupFilesController.py index 4c302cc2..6dafb79e 100644 --- a/FreeTAKServer/core/configuration/CreateStartupFilesController.py +++ b/FreeTAKServer/core/configuration/CreateStartupFilesController.py @@ -9,7 +9,7 @@ class CreateStartupFilesController: def __init__(self): self.file_dir = os.path.dirname(os.path.realpath(__file__)) self.dp_directory = PurePath(self.file_dir, DataPackageServerConstants().DATAPACKAGEFOLDER) - self.logs_directory = PurePath(LoggingConstants().PARENTPATH) + self.logs_directory = PurePath(config.LogFilePath) self.client_package = config.ClientPackages self.createFolder() diff --git a/FreeTAKServer/core/configuration/LoggingConstants.py b/FreeTAKServer/core/configuration/LoggingConstants.py index 8940e68b..115765d8 100644 --- a/FreeTAKServer/core/configuration/LoggingConstants.py +++ b/FreeTAKServer/core/configuration/LoggingConstants.py @@ -1,29 +1,22 @@ import os from pathlib import PurePath, Path +from FreeTAKServer.core.configuration.MainConfig import MainConfig +config = MainConfig.instance() + class LoggingConstants: def __init__(self, log_name = "FTS"): #main logging config - # if on a unix type system with /var/log put the logs there - if os.path.isdir('/var/log') and os.access('/var/log', os.W_OK): - self.PARENTPATH = '/var' - self.LOGDIRECTORY = 'log' - else: - # determine the log path the old way under the execution path - self.CURRENTPATH = os.path.dirname(os.path.realpath(__file__)) - self.CURRENTPATH = PurePath(self.CURRENTPATH) - self.PARENTPATH = str(self.CURRENTPATH.parents[0]) - self.LOGDIRECTORY = 'logs' - - # ensure directory exists - Path(PurePath(self.PARENTPATH, self.LOGDIRECTORY)).mkdir(parents=True, exist_ok=True) + + # ensure directory exists + Path(PurePath(config.LogFilePath)).mkdir(parents=True, exist_ok=True) self.LOGFORMAT = '%(levelname)s : %(asctime)s : %(filename)s:%(lineno)d : %(message)s' self.LOGNAME = log_name - self.ERRORLOG = str(PurePath(self.PARENTPATH, f"{self.LOGDIRECTORY}/{self.LOGNAME}_error.log")) - self.DEBUGLOG = str(PurePath(self.PARENTPATH, f"{self.LOGDIRECTORY}/{self.LOGNAME}_debug.log")) - self.INFOLOG = str(PurePath(self.PARENTPATH, f"{self.LOGDIRECTORY}/{self.LOGNAME}_info.log")) - self.HTTPLOG = str(PurePath(self.PARENTPATH, f"{self.LOGDIRECTORY}/{self.LOGNAME}_http.log")) + self.ERRORLOG = str(PurePath(f"{config.LogFilePath}/{self.LOGNAME}_error.log")) + self.DEBUGLOG = str(PurePath(f"{config.LogFilePath}/{self.LOGNAME}_debug.log")) + self.INFOLOG = str(PurePath(f"{config.LogFilePath}/{self.LOGNAME}_info.log")) + self.HTTPLOG = str(PurePath(f"{config.LogFilePath}/{self.LOGNAME}_http.log")) self.DELIMITER = ' ? ' self.MAXFILESIZE = 100000000 self.BACKUPCOUNT = 5 From 94c6e99d055cefbfacc8a6ae48e2e55e6488927b Mon Sep 17 00:00:00 2001 From: Stephen Dade Date: Wed, 11 Sep 2024 21:15:52 +1000 Subject: [PATCH 3/3] Logging: Set DigitalPy logging level to ERROR for file logs --- .../components/core/domain/configuration/logging.conf | 6 +++--- .../components/core/type/configuration/logging.conf | 6 +++--- .../core/xml_serializer/configuration/logging.conf | 6 +++--- .../extended/emergency/configuration/logging.conf | 6 +++--- .../components/extended/excheck/configuration/logging.conf | 6 +++--- .../components/extended/mission/configuration/logging.conf | 6 +++--- .../core/cot_management/configuration/logging.conf | 6 +++--- .../core/enterprise_sync/configuration/logging.conf | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/FreeTAKServer/components/core/domain/configuration/logging.conf b/FreeTAKServer/components/core/domain/configuration/logging.conf index 6ad96b69..b254b40c 100644 --- a/FreeTAKServer/components/core/domain/configuration/logging.conf +++ b/FreeTAKServer/components/core/domain/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_domain] -level=DEBUG +level=ERROR qualname=domain handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/components/core/type/configuration/logging.conf b/FreeTAKServer/components/core/type/configuration/logging.conf index de92cce7..433d8167 100644 --- a/FreeTAKServer/components/core/type/configuration/logging.conf +++ b/FreeTAKServer/components/core/type/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_type] -level=DEBUG +level=ERROR qualname=type handlers=fileHandler @@ -25,7 +25,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/components/core/xml_serializer/configuration/logging.conf b/FreeTAKServer/components/core/xml_serializer/configuration/logging.conf index 8b41a98e..a4f858d1 100644 --- a/FreeTAKServer/components/core/xml_serializer/configuration/logging.conf +++ b/FreeTAKServer/components/core/xml_serializer/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_xml_serializer] -level=DEBUG +level=ERROR qualname=xml_serializer handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/components/extended/emergency/configuration/logging.conf b/FreeTAKServer/components/extended/emergency/configuration/logging.conf index abf821d8..37fdb4e0 100644 --- a/FreeTAKServer/components/extended/emergency/configuration/logging.conf +++ b/FreeTAKServer/components/extended/emergency/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_emergency] -level=DEBUG +level=ERROR qualname=emergency handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/components/extended/excheck/configuration/logging.conf b/FreeTAKServer/components/extended/excheck/configuration/logging.conf index 447840ad..20a078fe 100644 --- a/FreeTAKServer/components/extended/excheck/configuration/logging.conf +++ b/FreeTAKServer/components/extended/excheck/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_excheck] -level=DEBUG +level=ERROR qualname=excheck handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/components/extended/mission/configuration/logging.conf b/FreeTAKServer/components/extended/mission/configuration/logging.conf index 25b96362..edf2f327 100644 --- a/FreeTAKServer/components/extended/mission/configuration/logging.conf +++ b/FreeTAKServer/components/extended/mission/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_mission] -level=DEBUG +level=ERROR qualname=mission handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/core/cot_management/configuration/logging.conf b/FreeTAKServer/core/cot_management/configuration/logging.conf index a50b23ed..468bfa36 100644 --- a/FreeTAKServer/core/cot_management/configuration/logging.conf +++ b/FreeTAKServer/core/cot_management/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_cotmanagement] -level=DEBUG +level=ERROR qualname=cotmanagement handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',) diff --git a/FreeTAKServer/core/enterprise_sync/configuration/logging.conf b/FreeTAKServer/core/enterprise_sync/configuration/logging.conf index 8644c1c0..7eb4359b 100644 --- a/FreeTAKServer/core/enterprise_sync/configuration/logging.conf +++ b/FreeTAKServer/core/enterprise_sync/configuration/logging.conf @@ -8,11 +8,11 @@ keys=stream_handler,fileHandler keys=formatter [logger_root] -level=DEBUG +level=ERROR handlers=fileHandler [logger_enterprisesync] -level=DEBUG +level=ERROR qualname=enterprisesync handlers=fileHandler @@ -24,7 +24,7 @@ args=(sys.stderr,) [handler_fileHandler] class=FileHandler -level=DEBUG +level=ERROR formatter=formatter args=('%(logfilename)s',)