Migrated configuration and logging to Envoy Common (#113)
* Moved client specific configuration to ClientConfig * Finished ClientConfig integration, checking init state in EnvoyLog * Migrated Config, ConfigItem and EnvoyLog to envoy-common * Updated envoy-common dependency to develop-SNAPSHOT
This commit is contained in:
@ -4,6 +4,7 @@ import java.awt.EventQueue;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -14,9 +15,10 @@ import javax.swing.SwingUtilities;
|
||||
import envoy.client.data.*;
|
||||
import envoy.client.net.Client;
|
||||
import envoy.client.net.WriteProxy;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
import envoy.data.Config;
|
||||
import envoy.data.Message;
|
||||
import envoy.exception.EnvoyException;
|
||||
import envoy.util.EnvoyLog;
|
||||
|
||||
/**
|
||||
* Starts the Envoy client and prompts the user to enter their name.<br>
|
||||
@ -48,13 +50,15 @@ public class Startup {
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Config config = Config.getInstance();
|
||||
ClientConfig config = ClientConfig.getInstance();
|
||||
|
||||
SwingUtilities.invokeLater(() -> chatWindow = new ChatWindow());
|
||||
|
||||
try {
|
||||
// Load the configuration from client.properties first
|
||||
config.load();
|
||||
Properties properties = new Properties();
|
||||
properties.load(Startup.class.getClassLoader().getResourceAsStream("client.properties"));
|
||||
config.load(properties);
|
||||
|
||||
// Override configuration values with command line arguments
|
||||
if (args.length > 0) config.load(args);
|
||||
@ -62,13 +66,13 @@ public class Startup {
|
||||
// Check if all mandatory configuration values have been initialized
|
||||
if (!config.isInitialized()) throw new EnvoyException("Configuration is not fully initialized");
|
||||
} catch (Exception e) {
|
||||
JOptionPane
|
||||
.showMessageDialog(null, "Error loading configuration values:\n" + e.toString(), "Configuration error", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Error loading configuration values:\n" + e, "Configuration error", JOptionPane.ERROR_MESSAGE);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Setup logger for the envoy package
|
||||
EnvoyLog.initialize(config);
|
||||
EnvoyLog.attach("envoy");
|
||||
EnvoyLog.setFileLevelBarrier(config.getFileLevelBarrier());
|
||||
EnvoyLog.setConsoleLevelBarrier(config.getConsoleLevelBarrier());
|
||||
@ -85,8 +89,7 @@ public class Startup {
|
||||
localDb = new PersistentLocalDb(new File(config.getHomeDirectory(), config.getLocalDB().getPath()));
|
||||
} catch (IOException e3) {
|
||||
logger.log(Level.SEVERE, "Could not initialize local database", e3);
|
||||
JOptionPane
|
||||
.showMessageDialog(null, "Could not initialize local database!\n" + e3, "Local database error", JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Could not initialize local database!\n" + e3, "Local database error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user