Feat: add log file on disk

This commit is contained in:
Laurent Clouet
2024-04-14 09:27:52 +00:00
committed by harlekin
parent 50ddc9ae3f
commit 595018b20b
4 changed files with 44 additions and 6 deletions

View File

@@ -95,6 +95,8 @@ public class Worker {
@Option(name = SettingsLoader.ARG_CONFIG, usage = "Specify the configuration file", required = false) private String config_file = null;
@Option(name = SettingsLoader.ARG_LOG_DIRECTORY, usage = "Specify the log directory", required = false) private String log_dir = null;
@Option(name = SettingsLoader.ARG_VERSION, usage = "Display application version", required = false, handler = VersionParameterHandler.class) private VersionParameterHandler versionHandler;
@Option(name = SettingsLoader.ARG_SHOW_GPU, usage = "Print available GPU devices and exit", required = false, handler = ListGpuParameterHandler.class) private ListGpuParameterHandler listGpuParameterHandler;
@@ -457,6 +459,10 @@ public class Worker {
settingsLoader.markLaunchSettings(List.of(args));
}
// config file and log file should be next to each other
String configFilePath = config.getConfigFilePath() != null ? config.getConfigFilePath() : OS.getOS().getDefaultConfigFilePath();
config.setLogDirectory(log_dir != null ? log_dir : (new File (configFilePath).getParent()));
Log.getInstance(config).debug("client version " + Configuration.jarVersion);
// Hostname change will overwrite the existing one (default or read from configuration file) but changes will be lost when the client closes