Merge branch 'feat/debug-vs-stdout' into 'master'
Fix: debug level and log on stdout are not the same See merge request sheepitrenderfarm/client!302
This commit is contained in:
@@ -70,6 +70,7 @@ import lombok.Data;
|
||||
private GPUDevice GPUDevice;
|
||||
private boolean detectGPUs;
|
||||
private boolean printLog;
|
||||
private boolean debugLevel;
|
||||
private List<Pair<Calendar, Calendar>> requestTime;
|
||||
private long shutdownTime;
|
||||
private String shutdownMode;
|
||||
@@ -104,6 +105,7 @@ import lombok.Data;
|
||||
this.storageDirectory = null;
|
||||
this.setCacheDir(cache_dir_);
|
||||
this.printLog = false;
|
||||
this.debugLevel = false;
|
||||
this.requestTime = null;
|
||||
this.shutdownTime = -1;
|
||||
this.shutdownMode = "soft";
|
||||
@@ -141,6 +143,7 @@ import lombok.Data;
|
||||
c + "GPUDevice: " + GPUDevice + n +
|
||||
c + "detectGPUs: " + detectGPUs + n +
|
||||
c + "printLog: " + printLog + n +
|
||||
c + "debugLog: " + debugLevel + n +
|
||||
c + "requestTime: " + requestTime + n +
|
||||
c + "shutdownTime: " + shutdownTime + n +
|
||||
c + "shutdownMode: " + shutdownMode + n +
|
||||
|
||||
@@ -33,6 +33,10 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Log {
|
||||
private final String LEVEL_DEBUG = "debug";
|
||||
private final String LEVEL_INFO = "info";
|
||||
private final String LEVEL_ERROR = "error";
|
||||
|
||||
private static Log instance = null;
|
||||
|
||||
private Map<Integer, ArrayList<String>> checkpoints = new HashMap<Integer, ArrayList<String>>();
|
||||
@@ -40,10 +44,12 @@ public class Log {
|
||||
private DateFormat dateFormat;
|
||||
|
||||
private boolean printStdOut;
|
||||
private boolean debugLevel;
|
||||
|
||||
private String logFile;
|
||||
|
||||
private Log(boolean print_, String logDirectory_) {
|
||||
private Log(boolean debugLevel_, boolean print_, String logDirectory_) {
|
||||
this.debugLevel = debugLevel_;
|
||||
this.printStdOut = print_;
|
||||
this.logFile = logDirectory_ + File.separator + "sheepit.log";
|
||||
this.lastCheckPoint = 0;
|
||||
@@ -56,7 +62,7 @@ public class Log {
|
||||
}
|
||||
|
||||
public void debug(int point_, String msg_) {
|
||||
this.append(point_, "debug", msg_);
|
||||
this.append(point_, LEVEL_DEBUG, msg_);
|
||||
}
|
||||
|
||||
public void info(String msg_) {
|
||||
@@ -64,7 +70,7 @@ public class Log {
|
||||
}
|
||||
|
||||
public void info(int point_, String msg_) {
|
||||
this.append(point_, "info", msg_);
|
||||
this.append(point_, LEVEL_INFO, msg_);
|
||||
}
|
||||
|
||||
public void error(String msg_) {
|
||||
@@ -72,10 +78,13 @@ public class Log {
|
||||
}
|
||||
|
||||
public void error(int point_, String msg_) {
|
||||
this.append(point_, "error", msg_);
|
||||
this.append(point_, LEVEL_ERROR, msg_);
|
||||
}
|
||||
|
||||
private synchronized void append(int point_, String level_, String msg_) {
|
||||
if (LEVEL_DEBUG.equals(level_) && this.debugLevel == false) {
|
||||
return;
|
||||
}
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
@@ -128,12 +137,14 @@ public class Log {
|
||||
if (instance == null) {
|
||||
String path = null;
|
||||
boolean print = false;
|
||||
boolean debug = false;
|
||||
if (config != null) {
|
||||
debug = config.isDebugLevel();
|
||||
print = config.isPrintLog();
|
||||
path = config.getLogDirectory() == null ? null : config.getLogDirectory();
|
||||
}
|
||||
|
||||
instance = new Log(print, path);
|
||||
instance = new Log(debug, print, path);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,9 @@ public class Worker {
|
||||
|
||||
@Option(name = SettingsLoader.ARG_RENDERTIME, usage = "Maximum time allow for each frame (in minutes)", required = false) private int max_rendertime = -1;
|
||||
|
||||
@Option(name = SettingsLoader.ARG_VERBOSE, usage = "Display full log", required = false) private boolean print_log = false;
|
||||
@Option(name = SettingsLoader.ARG_LOG_STDOUT, usage = "Display full log", required = false) private boolean print_log = false;
|
||||
|
||||
@Option(name = SettingsLoader.ARG_VERBOSE, usage = "Log DEBUG", required = false) private boolean log_debug = false;
|
||||
|
||||
@Option(name = SettingsLoader.ARG_REQUEST_TIME, usage = "H1:M1-H2:M2,H3:M3-H4:M4 Use the 24h format. For example to request job between 2am-8.30am and 5pm-11pm you should do -request-time 2:00-8:30,17:00-23:00 Caution, it's the requesting job time to get a project, not the working time", metaVar = "2:00-8:30,17:00-23:00", required = false) private String request_time = null;
|
||||
|
||||
@@ -138,6 +140,7 @@ public class Worker {
|
||||
|
||||
ComputeType compute_method = null;
|
||||
Configuration config = new Configuration(null, login, password);
|
||||
config.setDebugLevel(log_debug);
|
||||
config.setPrintLog(print_log);
|
||||
config.setPriority(priority);
|
||||
config.setDetectGPUs(!no_gpu_detection);
|
||||
|
||||
@@ -800,7 +800,7 @@ public class Settings implements Activity {
|
||||
.setSettings(config.getConfigFilePath(), login.getText(), new String(password.getPassword()), proxyText, hostnameText, method,
|
||||
selected_gpu, cpu_cores, max_ram, max_rendertime, getCachePath(config), getSharedPath(config), autoSignIn.isSelected(),
|
||||
useSysTray.isSelected(), headlessCheckbox.isSelected(), GuiSwing.type, themeOptionsGroup.getSelection().getActionCommand(),
|
||||
config.getPriority(), disableLargeDownloads.isSelected());
|
||||
config.getPriority(), disableLargeDownloads.isSelected(), config.isDebugLevel());
|
||||
|
||||
// wait for successful authentication (to store the public key)
|
||||
// or do we already have one?
|
||||
|
||||
Reference in New Issue
Block a user