Skip to content

Commit

Permalink
Add logging settings to mantid properties file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GuiMacielPereira committed Jan 3, 2025
1 parent 67e1255 commit 1c72316
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 0 additions & 1 deletion Mantid.user.properties

This file was deleted.

21 changes: 18 additions & 3 deletions src/mvesuvio/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/mvesuvio/util/analysis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 1c72316

Please sign in to comment.