Fix: debug level and log on stdout are not the same

This commit is contained in:
Laurent Clouet
2024-05-05 10:55:46 +00:00
parent 5aaa88cf1a
commit 96cca24990
5 changed files with 39 additions and 10 deletions

View File

@@ -65,6 +65,7 @@ public class SettingsLoader {
UI("ui"),
THEME("theme"),
LOG_DIR("log-dir"),
DEBUG("debug"),
DISABLE_LARGE_DOWNLOADS("disable-large-downloads");
String propertyName;
@@ -92,6 +93,7 @@ public class SettingsLoader {
public static final String ARG_MEMORY = "-memory";
public static final String ARG_RENDERTIME = "-rendertime";
public static final String ARG_VERBOSE = "--verbose";
public static final String ARG_LOG_STDOUT = "--log-stdout";
public static final String ARG_REQUEST_TIME = "-request-time";
public static final String ARG_SHUTDOWN = "-shutdown";
public static final String ARG_SHUTDOWN_MODE = "-shutdown-mode";
@@ -117,6 +119,7 @@ public class SettingsLoader {
private Option<String> password;
private Option<String> logDir;
private Option<String> debug;
private Option<String> proxy;
private Option<String> hostname;
private Option<String> computeMethod;
@@ -146,7 +149,7 @@ public class SettingsLoader {
public void setSettings(String path_, String login_, String password_, String proxy_, String hostname_,
ComputeType computeMethod_, GPUDevice gpu_, Integer cores_, Long maxRam_,
Integer maxRenderTime_, String cacheDir_, String sharedZip_, Boolean autoSignIn_, Boolean useSysTray_,
Boolean isHeadless, String ui_, String theme_, Integer priority_, Boolean disableLargeDownloads_) {
Boolean isHeadless, String ui_, String theme_, Integer priority_, Boolean disableLargeDownloads_, Boolean debug_) {
if (path_ == null) {
path = OS.getOS().getDefaultConfigFilePath();
}
@@ -166,6 +169,7 @@ public class SettingsLoader {
priority = setValue(priority_, priority, ARG_PRIORITY);
theme = setValue(theme_, theme, ARG_THEME);
disableLargeDownloads = setValue(disableLargeDownloads_.toString(), disableLargeDownloads, ARG_DISABLE_LARGE_DOWNLOADS);
debug = setValue(debug_.toString(), debug, ARG_VERBOSE);
if (cores_ > 0) {
cores = setValue(cores_.toString(), cores, ARG_CORES);
@@ -287,6 +291,7 @@ public class SettingsLoader {
setProperty(prop, configFileProp, PropertyNames.THEME, theme);
setProperty(prop, configFileProp, PropertyNames.DISABLE_LARGE_DOWNLOADS, disableLargeDownloads);
setProperty(prop, configFileProp, PropertyNames.LOG_DIR, logDir);
setProperty(prop, configFileProp, PropertyNames.DEBUG, debug);
prop.store(output, null);
}
catch (IOException io) {
@@ -393,6 +398,8 @@ public class SettingsLoader {
logDir = loadConfigOption(prop, PropertyNames.LOG_DIR, logDir, ARG_LOG_DIRECTORY);
debug = loadConfigOption(prop, PropertyNames.DEBUG, debug, ARG_VERBOSE);
if (prop.containsKey(PropertyNames.PRIORITY.propertyName)) {
int prio = Integer.parseInt(prop.getProperty(PropertyNames.PRIORITY.propertyName));
if (priority == null) {
@@ -542,6 +549,10 @@ public class SettingsLoader {
if (config.getLogDirectory() != null && logDir != null) {
config.setLogDirectory(logDir.getValue());
}
if (config.isDebugLevel() == false && debug != null) {
config.setDebugLevel(Boolean.parseBoolean(debug.getValue()));
}
}
private void initWithDefaults() {
@@ -565,11 +576,12 @@ public class SettingsLoader {
this.cores = new Option<>(String.valueOf(defaultConfigValues.getNbCores()), ARG_CORES);
this.disableLargeDownloads = new Option<>(String.valueOf(defaultConfigValues.isDisableLargeDownloads()), ARG_DISABLE_LARGE_DOWNLOADS);
this.logDir = null;
this.debug = null;
}
@Override public String toString() {
return String.format(
"SettingsLoader [path=%s, login=%s, password=%s, computeMethod=%s, gpu=%s, cacheDir=%s, sharedZip=%s, theme=%s, priority=%d, autosign=%s, usetray=%s, headless=%s, disableLargeDownloads=%s, logDir=%s]",
path, login, password, computeMethod, gpu, cacheDir, sharedZip, theme, priority, autoSignIn, useSysTray, headless, disableLargeDownloads, logDir);
"SettingsLoader [path=%s, login=%s, password=%s, computeMethod=%s, gpu=%s, cacheDir=%s, sharedZip=%s, theme=%s, priority=%d, autosign=%s, usetray=%s, headless=%s, disableLargeDownloads=%s, logDir=%s, debug=%s]",
path, login, password, computeMethod, gpu, cacheDir, sharedZip, theme, priority, autoSignIn, useSysTray, headless, disableLargeDownloads, logDir, debug);
}
}