mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'Logging' into 'master'
Added dependencies for slf4j See merge request !49
This commit is contained in:
@@ -43,8 +43,23 @@
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.26-incubating</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j-impl -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -1,16 +1,65 @@
|
||||
package seng302;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.client.ClientPacketParser;
|
||||
import seng302.client.ClientState;
|
||||
import seng302.models.PolarTable;
|
||||
|
||||
public class App extends Application {
|
||||
private static Logger logger = LoggerFactory.getLogger(App.class);
|
||||
|
||||
public static void parseArgs(String[] args) throws ParseException {
|
||||
Options options = new Options();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd;
|
||||
|
||||
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||
|
||||
options.addOption("debugLevel", true, "Set the application debug level");
|
||||
|
||||
cmd = parser.parse(options, args);
|
||||
|
||||
if (cmd.hasOption("debugLevel")){
|
||||
|
||||
switch (cmd.getOptionValue("debugLevel")){
|
||||
case "DEBUG":
|
||||
rootLogger.setLevel(Level.DEBUG);
|
||||
break;
|
||||
|
||||
case "ALL":
|
||||
rootLogger.setLevel(Level.ALL);
|
||||
break;
|
||||
|
||||
case "WARNING":
|
||||
rootLogger.setLevel(Level.WARN);
|
||||
break;
|
||||
|
||||
case "ERROR":
|
||||
rootLogger.setLevel(Level.ERROR);
|
||||
break;
|
||||
|
||||
case "INFO":
|
||||
rootLogger.setLevel(Level.INFO);
|
||||
|
||||
case "TRACE":
|
||||
rootLogger.setLevel(Level.TRACE);
|
||||
|
||||
default:
|
||||
rootLogger.setLevel(Level.ALL);
|
||||
}
|
||||
} else{
|
||||
rootLogger.setLevel(Level.WARN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
@@ -25,6 +74,7 @@ public class App extends Application {
|
||||
// primaryStage.setMaximized(true);
|
||||
|
||||
primaryStage.show();
|
||||
|
||||
primaryStage.setOnCloseRequest(e -> {
|
||||
ClientPacketParser.appClose();
|
||||
System.exit(0);
|
||||
@@ -34,6 +84,12 @@ public class App extends Application {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
parseArgs(args);
|
||||
} catch (ParseException e) {
|
||||
logger.error("Could not parse command line arguments");
|
||||
}
|
||||
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user