Merge branch 'develop' into f/logging

This commit is contained in:
delvh 2019-11-29 21:04:44 +01:00 committed by GitHub
commit eed12695bb
2 changed files with 19 additions and 18 deletions

View File

@ -32,7 +32,7 @@ public class Config {
*
* @param properties a {@link Properties} object containing information about
* the server and port, as well as the path to the local
* database
* database and the synchronization timeout
* @since Envoy v0.1-alpha
*/
public void load(Properties properties) {
@ -64,8 +64,6 @@ public class Config {
case "-db":
localDB = new File(args[++i]);
}
if (localDB == null) localDB = new File(".\\localDB");
if (syncTimeout == 0) syncTimeout = 1000;
}
/**

View File

@ -32,9 +32,8 @@ public class Startup {
logger.setLevel(Level.ALL);
Config config = Config.getInstance();
if (args.length > 0) {
config.load(args);
} else {
// Load the configuration from client.properties first
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Properties configProperties = new Properties();
@ -43,10 +42,15 @@ public class Startup {
} catch (IOException e) {
e.printStackTrace();
}
}
// Override configuration values with command line arguments
if (args.length > 0)
config.load(args);
if (!config.isInitialized()) {
logger.warning("Server or port are not defined. Exiting...");
JOptionPane.showMessageDialog(null, "Error loading configuration values.", "Configuration error",
JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
@ -63,8 +67,7 @@ public class Startup {
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"Error while loading local database: " + e.toString() + "\nChats will not be stored locally.",
"Local DB error",
JOptionPane.WARNING_MESSAGE);
"Local DB error", JOptionPane.WARNING_MESSAGE);
}
EventQueue.invokeLater(() -> {