From 7c5329fd54fdcb3abaf2bb6efa65454008af97c9 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Wed, 14 Oct 2020 13:43:29 +0200 Subject: [PATCH] better logging --- README.md | 9 +- auto-cream-api.iml | 4 + pom.xml | 13 +- .../xyz/jeddunk/autocreamapi/Controller.java | 131 ++++++++++-------- .../SearchResultWindowController.java | 17 ++- .../autocreamapi/util/CreamApiConfig.java | 20 ++- .../autocreamapi/util/SteamAppsListCache.java | 41 +++--- src/main/resources/logback.xml | 50 +++++++ src/main/resources/mainWindow.fxml | 4 +- 9 files changed, 201 insertions(+), 88 deletions(-) create mode 100644 src/main/resources/logback.xml diff --git a/README.md b/README.md index 7f16a10..096a2cf 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Download the latest release and extract it into any folder (e.g. `%USERPROFILE%\ * Select a language and tick the options if needed. * Click on *"Save"*. -### Java 11 +### Java 11/Java 14 *WIP* @@ -58,3 +58,10 @@ The following dependencies are licensed under the Apache License 2.0: The following dependencies are licensed under the MIT License: * jsoup * Unirest-Java +* slf4j +* Copy Rename Maven Plugin + +The following dependencies are licensed under the GPL2 License: +* fuzzywuzzy + +Logback is dual-licensed under the EPL v1.0 and the LGPL 2.1. diff --git a/auto-cream-api.iml b/auto-cream-api.iml index c390abc..9654196 100644 --- a/auto-cream-api.iml +++ b/auto-cream-api.iml @@ -75,5 +75,9 @@ + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 95ef2f3..7908186 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ xyz.jeddunk auto-cream-api - 1.1.0 + 1.2.0 UTF-8 @@ -208,6 +208,15 @@ copy-rename-maven-plugin 1.0.1 - + + ch.qos.logback + logback-classic + 1.2.3 + + + org.fusesource.jansi + jansi + 1.18 + \ No newline at end of file diff --git a/src/main/java/xyz/jeddunk/autocreamapi/Controller.java b/src/main/java/xyz/jeddunk/autocreamapi/Controller.java index 5f64732..2046fb3 100644 --- a/src/main/java/xyz/jeddunk/autocreamapi/Controller.java +++ b/src/main/java/xyz/jeddunk/autocreamapi/Controller.java @@ -34,12 +34,15 @@ import javafx.scene.control.*; import javafx.stage.*; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.configuration2.ex.ConfigurationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import xyz.jeddunk.autocreamapi.pojo.App; import xyz.jeddunk.autocreamapi.util.CreamApiConfig; import xyz.jeddunk.autocreamapi.util.CreamApiDllHandler; import xyz.jeddunk.autocreamapi.util.SteamAppsListCache; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -52,31 +55,29 @@ import java.util.stream.Stream; public class Controller implements Initializable { + final Logger logger = LoggerFactory.getLogger(Controller.class); + + private static final String GLYPH_FAILURE = "TIMES"; + private static final String GLYPH_SUCCESS = "CHECK"; + private static final Color COLOR_FAILURE = Color.web("#E53935"); + private static final Color COLOR_SUCCESS = Color.web("#43A047"); private static final String REGEX = "(?steam_api(?:64)?.dll)$"; - public Label creamApiDllApplied; - public Label creamApiConfigExists; - public FontAwesomeIconView creamApiDllAppliedIcon; - public FontAwesomeIconView creamApiConfigExistsIcon; + private CreamApiDllHandler handler = null; + private final CreamApiConfig config = CreamApiConfig.getInstance(); + private final SteamAppsListCache cache = new SteamAppsListCache(); private boolean is64Bit; private boolean isSameFile; - { - try { - handler = CreamApiDllHandler.getInstance(); - } catch (IOException e) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("CreamAPI DLLs missing!"); - alert.setHeaderText("CreamAPI DLL files can't be found!"); - alert.setContentText("Please download CreamAPI and extract the non-log " + - "version in the same folder as Auto-CreamAPI!\nThe program will now close."); - alert.showAndWait(); - System.exit(10); - } - } - private final CreamApiConfig config = CreamApiConfig.getInstance(); - private final SteamAppsListCache cache = new SteamAppsListCache(); + @FXML + public Label creamApiDllApplied; + @FXML + public Label creamApiConfigExists; + @FXML + public FontAwesomeIconView creamApiDllAppliedIcon; + @FXML + public FontAwesomeIconView creamApiConfigExistsIcon; @FXML public Label state_label; @FXML @@ -96,7 +97,7 @@ public class Controller implements Initializable { @FXML public CheckBox unlock_all_checkbox; @FXML - public CheckBox use_steamdb_dlc; + public CheckBox steamdb_dlc_checkbox; @FXML public Button reset_button; @FXML @@ -106,16 +107,32 @@ public class Controller implements Initializable { @FXML public Button path_button; @FXML - public Button retrieveDlcList_button; + public Button getDlcList_button; private String steamApiPathString; + { + try { + handler = CreamApiDllHandler.getInstance(); + } catch (FileNotFoundException e) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("CreamAPI DLLs missing!"); + alert.setHeaderText("CreamAPI DLL files can't be found!"); + alert.setContentText("Please download CreamAPI and extract the non-log " + + "version in the same folder as Auto-CreamAPI!\nThe program will now close."); + alert.showAndWait(); + System.exit(2); + } catch (IOException e) { + e.printStackTrace(); + } + } + public Controller() { } @FXML @Override public void initialize(URL location, ResourceBundle resources) { - use_steamdb_dlc.setSelected(true); + steamdb_dlc_checkbox.setSelected(true); appId_textfield.textProperty().addListener(appIdChangesGameName()); game_name_textfield.setOnKeyReleased(event -> { KeyCode code = event.getCode(); @@ -131,6 +148,7 @@ public class Controller implements Initializable { generate_tooltips(); fix_dlc_textarea_prompt_text(); reset(true); + state_label.setText("Ready."); } private void read() { @@ -145,8 +163,8 @@ public class Controller implements Initializable { } private void emptyFields() { - creamApiDllAppliedIcon.setGlyphName("TIMES"); - creamApiConfigExistsIcon.setGlyphName("TIMES"); + /*setIndicator(creamApiDllApplied, creamApiDllAppliedIcon, COLOR_FAILURE, GLYPH_FAILURE); + setIndicator(creamApiConfigExists, creamApiConfigExistsIcon, COLOR_FAILURE, GLYPH_FAILURE);*/ appId_textfield.setText(""); dlc_textarea.setText(""); game_name_textfield.setText(""); @@ -164,6 +182,12 @@ public class Controller implements Initializable { Tooltip extra_protection_tooltip = new Tooltip("\"extra protection\""); extra_protection_checkbox.setTooltip(extra_protection_tooltip); Tooltip.install(extra_protection_checkbox, extra_protection_tooltip); + + Tooltip steamdb_dlc_tooltip = new Tooltip("Additionally get DLC data from SteamDB.\n" + + "Especially useful for DLC that is not listed on the Steam Store.\n" + + "This sometimes doesn't work because SteamDB may block access for scrapers."); + steamdb_dlc_checkbox.setTooltip(steamdb_dlc_tooltip); + Tooltip.install(steamdb_dlc_checkbox, steamdb_dlc_tooltip); } private ChangeListener appIdChangesGameName() { @@ -196,10 +220,10 @@ public class Controller implements Initializable { state_label.setText("Successfully reset all fields!"); } } catch (NoSuchElementException e) { - System.err.println("Error reading cream_api.ini! " + + logger.warn("Error reading cream_api.ini! " + "This can be ignored if setting up CreamAPI for the first time."); } catch (NullPointerException e) { - System.err.println("Can't fill out fields, no configuration file set!"); + logger.warn("Can't fill out fields, no configuration file set!"); if (!silent) { state_label.setText("Could not reset fields, no configuration file set!"); } @@ -208,8 +232,6 @@ public class Controller implements Initializable { } private void updateIndicators() { - Color colorSuccess = Color.web("#43A047"); - Color colorFailure = Color.web("#E53935"); try { is64Bit = false; if (!steamApiPathString.isEmpty()) { @@ -221,36 +243,30 @@ public class Controller implements Initializable { String md5 = DigestUtils.md5Hex(is); isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit)); if (isSameFile) { - creamApiDllApplied.setTextFill(colorSuccess); - creamApiDllAppliedIcon.setFill(colorSuccess); - creamApiDllAppliedIcon.setGlyphName("CHECK"); + setIndicator(creamApiDllApplied, creamApiDllAppliedIcon, COLOR_SUCCESS, GLYPH_SUCCESS); } else { - creamApiDllApplied.setTextFill(colorFailure); - creamApiDllAppliedIcon.setFill(colorFailure); - creamApiDllAppliedIcon.setGlyphName("TIMES"); + setIndicator(creamApiDllApplied, creamApiDllAppliedIcon, COLOR_FAILURE, GLYPH_FAILURE); } Path configPath = Paths.get(config.getPath()); if (Files.exists(configPath) && Files.size(configPath) > 0L) { - creamApiConfigExists.setTextFill(colorSuccess); - creamApiConfigExistsIcon.setFill(colorSuccess); - creamApiConfigExistsIcon.setGlyphName("CHECK"); + setIndicator(creamApiConfigExists, creamApiConfigExistsIcon, COLOR_SUCCESS, GLYPH_SUCCESS); } else { - creamApiConfigExists.setTextFill(colorFailure); - creamApiConfigExistsIcon.setFill(colorFailure); - creamApiConfigExistsIcon.setGlyphName("TIMES"); + setIndicator(creamApiConfigExists, creamApiConfigExistsIcon, COLOR_FAILURE, GLYPH_FAILURE); } } } catch (Exception e) { - System.err.println("Error! Resetting visual indicators!"); - creamApiDllApplied.setTextFill(colorFailure); - creamApiDllAppliedIcon.setFill(colorFailure); - creamApiDllAppliedIcon.setGlyphName("TIMES"); - creamApiConfigExists.setTextFill(colorFailure); - creamApiConfigExistsIcon.setFill(colorFailure); - creamApiConfigExistsIcon.setGlyphName("TIMES"); + logger.warn("Resetting visual indicators!"); + setIndicator(creamApiDllApplied, creamApiDllAppliedIcon, COLOR_FAILURE, GLYPH_FAILURE); + setIndicator(creamApiConfigExists, creamApiConfigExistsIcon, COLOR_FAILURE, GLYPH_FAILURE); } } + private void setIndicator(Label label, FontAwesomeIconView icon, Color color, String glyphName) { + label.setTextFill(color); + icon.setFill(color); + icon.setGlyphName(glyphName); + } + public void save() { Service s = new Service() { @Override @@ -271,7 +287,7 @@ public class Controller implements Initializable { e.printStackTrace(); cancel(); } catch (NullPointerException e) { - System.err.println("No configuration file set!"); + logger.warn("No configuration file set!"); cancel(); } updateIndicators(); @@ -298,12 +314,14 @@ public class Controller implements Initializable { public void getAppId() { final List games = cache.findListOfGames(game_name_textfield.getText()); if (games.isEmpty()) { + logger.info("No game name was given, setting AppID to \"-1\"!"); appId_textfield.setText("-1"); } else if (games.size() == 1) { App game = games.get(0); game_name_textfield.setText(game.getName()); appId_textfield.setText(String.valueOf(game.getAppId())); } else { + logger.info("Multiple results found, opening search result window!"); try { URL resource = ClassLoader.getSystemResource("searchResultWindow.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(resource); @@ -327,7 +345,7 @@ public class Controller implements Initializable { public void unlockAll_disableDlcTextArea() { dlc_textarea.setDisable(unlock_all_checkbox.isSelected()); - retrieveDlcList_button.setDisable(unlock_all_checkbox.isSelected()); + getDlcList_button.setDisable(unlock_all_checkbox.isSelected()); } /** @@ -342,7 +360,7 @@ public class Controller implements Initializable { @Override protected Void call() { Map collect = - cache.getDlcMap(appId_textfield.getText(), use_steamdb_dlc.isSelected()); + cache.getDlcMap(appId_textfield.getText(), steamdb_dlc_checkbox.isSelected()); StringBuilder sb = new StringBuilder(); collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n")); dlc_textarea.setText(sb.toString()); @@ -373,16 +391,16 @@ public class Controller implements Initializable { new FileChooser.ExtensionFilter("Steam API DLL", "steam_api.dll", "steam_api64.dll"); chooser.getExtensionFilters().add(filter); - final File file = chooser.showOpenDialog(path_button.getScene().getWindow()); + File file = chooser.showOpenDialog(path_button.getScene().getWindow()); try { config.setConfig(file.getParent() + "\\cream_api.ini"); + path_textfield.setText(file.getParent()); + steamApiPathString = file.getAbsolutePath(); } catch (ConfigurationException | IOException e) { e.printStackTrace(); } catch (NullPointerException e) { - System.err.println("Could not set config file location! Did you cancel the file chooser?"); + logger.warn("Could not set config file location! Did you cancel the file chooser?"); } - path_textfield.setText(file.getParent()); - steamApiPathString = file.getAbsolutePath(); emptyFields(); reset(true); state_label.setText("Ready."); @@ -406,7 +424,8 @@ public class Controller implements Initializable { Path dir = path.getParent(); Path secondDll = Paths.get(dir.toString() + secondDllString); if (Files.exists(secondDll)) { - System.out.println("Alternative DLL found!"); + //System.out.println("Alternative DLL found!"); + logger.info("Second DLL found: (" + secondDll.toString() + ")!"); InputStream is = Files.newInputStream(secondDll); String md5 = DigestUtils.md5Hex(is); boolean isSameFile1 = Objects.equals(md5, handler.getDllMd5(!is64Bit)); @@ -441,7 +460,7 @@ public class Controller implements Initializable { save_button.setDisable(b); getAppId_button.setDisable(b); path_button.setDisable(b); - retrieveDlcList_button.setDisable(b); + getDlcList_button.setDisable(b); } public void resetFromButton() { diff --git a/src/main/java/xyz/jeddunk/autocreamapi/SearchResultWindowController.java b/src/main/java/xyz/jeddunk/autocreamapi/SearchResultWindowController.java index e1adaad..71ff04c 100644 --- a/src/main/java/xyz/jeddunk/autocreamapi/SearchResultWindowController.java +++ b/src/main/java/xyz/jeddunk/autocreamapi/SearchResultWindowController.java @@ -20,14 +20,20 @@ import javafx.scene.control.cell.TreeItemPropertyValueFactory; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import xyz.jeddunk.autocreamapi.pojo.App; import java.net.URL; import java.util.List; import java.util.ResourceBundle; +import static java.text.MessageFormat.format; + public class SearchResultWindowController implements Initializable { + final Logger logger = LoggerFactory.getLogger(SearchResultWindowController.class); + @FXML public Button okButton; @FXML @@ -62,6 +68,7 @@ public class SearchResultWindowController implements Initializable { public void confirm() { App app = gameTable.getSelectionModel().getSelectedItem().getValue(); + logger.info(format("Game selected: {0} ({1})!", app.getName(), app.getAppId())); parent.game_name_textfield.setText(app.getName()); parent.appId_textfield.setText(String.valueOf(app.getAppId())); Stage current = (Stage) okButton.getScene().getWindow(); @@ -69,8 +76,9 @@ public class SearchResultWindowController implements Initializable { } public void cancel() { - parent.game_name_textfield.setText(""); - parent.appId_textfield.setText("-1"); + logger.info("Closing window without setting game!"); + /*parent.game_name_textfield.setText(""); + parent.appId_textfield.setText("-1");*/ Stage current = (Stage) cancelButton.getScene().getWindow(); current.close(); } @@ -89,11 +97,12 @@ public class SearchResultWindowController implements Initializable { } lastTime = currentTime; if (isDblClicked) { - App app = gameTable.getSelectionModel().getSelectedItem().getValue(); + /*App app = gameTable.getSelectionModel().getSelectedItem().getValue(); parent.game_name_textfield.setText(app.getName()); parent.appId_textfield.setText(String.valueOf(app.getAppId())); Stage current = (Stage) gameTable.getScene().getWindow(); - current.close(); + current.close();*/ + confirm(); } } } diff --git a/src/main/java/xyz/jeddunk/autocreamapi/util/CreamApiConfig.java b/src/main/java/xyz/jeddunk/autocreamapi/util/CreamApiConfig.java index 041c420..fa1ef89 100644 --- a/src/main/java/xyz/jeddunk/autocreamapi/util/CreamApiConfig.java +++ b/src/main/java/xyz/jeddunk/autocreamapi/util/CreamApiConfig.java @@ -19,12 +19,18 @@ import org.apache.commons.configuration2.*; import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; import org.apache.commons.configuration2.builder.fluent.Configurations; import org.apache.commons.configuration2.ex.ConfigurationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; -import java.text.MessageFormat; import java.util.*; +import static java.text.MessageFormat.format; + public class CreamApiConfig { + + final Logger logger = LoggerFactory.getLogger(CreamApiConfig.class); + private static CreamApiConfig configInstance; private static final Configurations CONFIGS = new Configurations(); @@ -48,7 +54,7 @@ public class CreamApiConfig { config = CONFIGS.ini(path); config.setCommentLeadingCharsUsedInInput(";"); } catch (ConfigurationException e) { - System.err.println("No config file found in default location!"); + logger.warn("No config file found in default location!"); //e.printStackTrace(); } @@ -88,10 +94,10 @@ public class CreamApiConfig { try { read(); } catch (NoSuchElementException e) { - System.err.println("Error reading cream_api.ini! " + + logger.warn("Error reading cream_api.ini! " + "This can be ignored if setting up CreamAPI for the first time."); } catch (NullPointerException e) { - System.err.println("Can't fill out fields, no configuration file set!"); + logger.warn("Can't fill out fields, no configuration file set!"); } } @@ -151,7 +157,7 @@ public class CreamApiConfig { Arrays.stream(str.split("\\R+")).forEach(line -> { final String[] split = line.split("\\s*=\\s*", 2); if (split.length == 2) dlc.put(Integer.parseInt(split[0]), split[1]); - else System.err.println(MessageFormat.format("Error while splitting line: \"{0}\"", line)); + else logger.error(format("Error while splitting line: \"{0}\"", line)); }); } @@ -204,9 +210,9 @@ public class CreamApiConfig { public void setConfig(String path) throws ConfigurationException, IOException { File file = new File(path); if (file.createNewFile()) { - System.out.println("New config file created!"); + logger.info("New config file created!"); } else { - System.out.println("Using existing config file!"); + logger.info("Using existing config file!"); } this.config = CONFIGS.ini(path); this.config.setCommentLeadingCharsUsedInInput(";"); diff --git a/src/main/java/xyz/jeddunk/autocreamapi/util/SteamAppsListCache.java b/src/main/java/xyz/jeddunk/autocreamapi/util/SteamAppsListCache.java index d9ed9a7..76cf578 100644 --- a/src/main/java/xyz/jeddunk/autocreamapi/util/SteamAppsListCache.java +++ b/src/main/java/xyz/jeddunk/autocreamapi/util/SteamAppsListCache.java @@ -27,6 +27,8 @@ import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import xyz.jeddunk.autocreamapi.pojo.App; import xyz.jeddunk.autocreamapi.pojo.SteamAppsList; import xyz.jeddunk.autocreamapi.util.env.MainEnv; @@ -40,6 +42,8 @@ import java.util.stream.Collectors; public class SteamAppsListCache { + final Logger logger = LoggerFactory.getLogger(SteamAppsListCache.class); + private SteamAppsList list = new SteamAppsList(); private final File cacheFile = new File("steamapps.json"); private MainEnv env; @@ -51,6 +55,7 @@ public class SteamAppsListCache { env = (MainEnv) envDefault.newInstance(); // System.out.println(env.getKey()); } catch (ClassNotFoundException e) { + logger.debug("Default environment missing, using main environemnt..."); env = new MainEnv(); } catch (IllegalAccessException | InstantiationException e) { // Only thrown by newInstance() @@ -60,16 +65,16 @@ public class SteamAppsListCache { try { getListFromFile(); } catch (FileNotFoundException e) { - System.err.println("File does not exist, trying to create steamapps.json for the first time..."); + logger.info("File does not exist, trying to create steamapps.json for the first time..."); //fileFound = false; sync(); } catch (JsonSyntaxException e) { - System.err.println("File seems to be corrupt, trying to recreate steamapps.json..."); + logger.warn("File seems to be corrupt, trying to recreate steamapps.json..."); //fileFound = false; sync(); } if (Instant.now().isAfter(list.getTimestamp().plus(Duration.ofDays(3)))) { - System.err.println("List in file is not recent!"); + logger.info("List in file is not recent!"); sync(); } } @@ -109,7 +114,7 @@ public class SteamAppsListCache { } private void getListFromApi() { - System.out.println("Trying to get SteamAppList from API..."); + logger.info("Trying to get SteamAppList from API..."); List apps = getApps(); list.setTimestamp(Instant.now()); list.setSteamAppsList(apps); @@ -125,24 +130,24 @@ public class SteamAppsListCache { } private void saveListToFile() throws IOException { - System.out.println("Trying to save SteamAppList to file \"" + cacheFile.getAbsolutePath() + "\"..."); + logger.info("Trying to save SteamAppList to file \"" + cacheFile.getAbsolutePath() + "\"..."); Gson gson = new Gson(); String jsonString = gson.toJson(list); BufferedWriter fOut = new BufferedWriter(new FileWriter(cacheFile)); fOut.write(jsonString); fOut.close(); - System.out.println("Successfully saved SteamAppList to file \"" + cacheFile.getAbsolutePath() + "\"..."); + logger.info("Successfully saved SteamAppList to file \"" + cacheFile.getAbsolutePath() + "\"..."); } private void getListFromFile() throws FileNotFoundException, JsonSyntaxException { - System.out.println("Trying to get SteamAppList from file \"" + cacheFile.getAbsolutePath() + "\"..."); + logger.info("Trying to get SteamAppList from file \"" + cacheFile.getAbsolutePath() + "\"..."); BufferedReader fIn = new BufferedReader(new FileReader(cacheFile)); String json = fIn.lines().collect(Collectors.joining()); final Type type = new TypeToken() { }.getType(); Gson gson = new Gson(); list = gson.fromJson(json, type); - System.out.println("Successfully got SteamAppList from file \"" + cacheFile.getAbsolutePath() + "\"..."); + logger.info("Successfully got SteamAppList from file \"" + cacheFile.getAbsolutePath() + "\"..."); } public Map getDlcMap(String appId, boolean use_steamdb) { @@ -164,13 +169,15 @@ public class SteamAppsListCache { steamStoreDLCs.put(Integer.parseInt(dlc_id), dlc_name); } } catch (HttpStatusException e) { + logger.error(e.getUrl()); if (e.getStatusCode() == 404) { - System.err.println("App ID empty or not found! (HTTP Status Code: 404)"); + logger.error("App ID empty or not found! (HTTP Status Code: 404)"); } else { - System.err.printf("Error occurred while trying to get list of DLCs " + - "(HTTP Status Code: %d)%n", e.getStatusCode()); + /*System.err.printf("Error occurred while trying to get list of DLCs " + + "(HTTP Status Code: %d)%n", e.getStatusCode());*/ + logger.error("Error occurred while trying to get list of DLCs " + + "(HTTP Status Code: " + e.getStatusCode() + ")"); } - System.err.println(e.getUrl()); } catch (NullPointerException | IOException e) { // ignore } @@ -194,13 +201,15 @@ public class SteamAppsListCache { steamDbDLCs.put(Integer.parseInt(dlc_id), dlc_name); } } catch (HttpStatusException e) { + logger.error(e.getUrl()); if (e.getStatusCode() == 404) { - System.err.println("App ID empty or not found! (HTTP Status Code: 404)"); + logger.error("App ID empty or not found! (HTTP Status Code: 404)"); } else { - System.err.printf("Error occurred while trying to get list of DLCs " + - "(HTTP Status Code: %d)%n", e.getStatusCode()); + /*System.err.printf("Error occurred while trying to get list of DLCs " + + "(HTTP Status Code: %d)%n", e.getStatusCode());*/ + logger.error("Error occurred while trying to get list of DLCs " + + "(HTTP Status Code: " + e.getStatusCode() + ")"); } - System.err.println(e.getUrl()); } catch (NullPointerException | IOException e) { // ignore } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..b6e52c2 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + ${PATTERN} + + + + + + autocreamapi_${bySecond}.log + + ${PATTERN} + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mainWindow.fxml b/src/main/resources/mainWindow.fxml index 44f9a74..f8cdb6e 100644 --- a/src/main/resources/mainWindow.fxml +++ b/src/main/resources/mainWindow.fxml @@ -67,7 +67,7 @@ - @@ -87,7 +87,7 @@ - +