From 1c723162ea1862f3ddf004dd42ab2313c6252c92 Mon Sep 17 00:00:00 2001 From: GuiMacielPereira Date: Fri, 3 Jan 2025 14:07:19 +0000 Subject: [PATCH] Add logging settings to mantid properties file Logging settings are added during config command. Current downside is that if logging settings are set to mantid properties when mantid is open, mantid needs to be closed and opened again for changes to take place. --- Mantid.user.properties | 1 - src/mvesuvio/main/__init__.py | 21 ++++++++++++++++++--- src/mvesuvio/util/analysis_helpers.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) delete mode 100644 Mantid.user.properties diff --git a/Mantid.user.properties b/Mantid.user.properties deleted file mode 100644 index 7d70a1df..00000000 --- a/Mantid.user.properties +++ /dev/null @@ -1 +0,0 @@ -UpdateInstrumentDefinitions.OnStartup = 0 \ No newline at end of file diff --git a/src/mvesuvio/main/__init__.py b/src/mvesuvio/main/__init__.py index 7295faf9..517a64ba 100644 --- a/src/mvesuvio/main/__init__.py +++ b/src/mvesuvio/main/__init__.py @@ -44,6 +44,9 @@ def __set_up_parser(): def __setup_config(args): + + __set_logging_properties() + config_dir = handle_config.VESUVIO_CONFIG_PATH handle_config.setup_config_dir(config_dir) ipfolder_dir = handle_config.VESUVIO_IPFOLDER_PATH @@ -80,10 +83,22 @@ def __setup_config(args): handle_config.check_dir_exists("IP folder", ipfolder_dir) +def __set_logging_properties(): + from mantid.kernel import ConfigService + ConfigService.setString("logging.loggers.root.channel.class", "SplitterChannel") + ConfigService.setString("logging.loggers.root.channel.channel1", "consoleChannel") + ConfigService.setString("logging.loggers.root.channel.channel2", "fileChannel") + ConfigService.setString("logging.channels.consoleChannel.class", "ConsoleChannel") + ConfigService.setString("logging.channels.fileChannel.class", "FileChannel") + ConfigService.setString("logging.channels.fileChannel.path", "mantid.log") + ConfigService.setString("logging.channels.fileChannel.formatter.class", "PatternFormatter") + ConfigService.setString("logging.channels.fileChannel.formatter.pattern", "%Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t") + mantid_properties_file = path.join(ConfigService.getPropertiesDir(), "Mantid.properties") + ConfigService.saveConfig(mantid_properties_file) + return + + def __run_analysis(): - environ["MANTIDPROPERTIES"] = path.join( - handle_config.VESUVIO_CONFIG_PATH, "Mantid.user.properties" - ) from mvesuvio.main.run_routine import Runner Runner().run() diff --git a/src/mvesuvio/util/analysis_helpers.py b/src/mvesuvio/util/analysis_helpers.py index b2453bce..599e225b 100644 --- a/src/mvesuvio/util/analysis_helpers.py +++ b/src/mvesuvio/util/analysis_helpers.py @@ -59,7 +59,7 @@ def is_hydrogen_present(masses) -> bool: def ws_history_matches_inputs(runs, mode, ipfile, ws_path): if not (ws_path.is_file()): - logger.notice("Cached workspace not found") + logger.notice(f"Cached workspace not found at {ws_path}") return False ws = Load(Filename=str(ws_path))