From a3f7c826243a9c5685a636918f4e54c20b4dff45 Mon Sep 17 00:00:00 2001 From: ZQ Date: Mon, 15 May 2023 23:45:04 +0800 Subject: [PATCH] Make file-related log messages more informative Let's make file-related log messages more informative, as follows: * include the file location when referring to a file * use a more informative term: prefs -> preferences --- src/main/java/seedu/address/MainApp.java | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index e24d87fb..0187d8c1 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -79,14 +79,17 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { try { addressBookOptional = storage.readAddressBook(); if (!addressBookOptional.isPresent()) { - logger.info("Creating a new data file populated with a sample AddressBook"); + logger.info("Creating a new data file " + storage.getAddressBookFilePath() + + " populated with a sample AddressBook."); } initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); } catch (DataConversionException e) { - logger.warning("Data file not in the correct format. Will be starting with an empty AddressBook"); + logger.warning("Data file at " + storage.getAddressBookFilePath() + " is not in the correct format." + + " Will be starting with an empty AddressBook."); initialData = new AddressBook(); } catch (IOException e) { - logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook"); + logger.warning("Problem while reading from the file " + storage.getAddressBookFilePath() + + ". Will be starting with an empty AddressBook."); initialData = new AddressBook(); } @@ -118,12 +121,12 @@ protected Config initConfig(Path configFilePath) { try { Optional configOptional = ConfigUtil.readConfig(configFilePathUsed); if (!configOptional.isPresent()) { - logger.info("Creating new config file."); + logger.info("Creating new config file " + configFilePathUsed); } initializedConfig = configOptional.orElse(new Config()); } catch (DataConversionException e) { - logger.warning("Config file at " + configFilePathUsed + " is not in the correct format. " - + "Using default config properties"); + logger.warning("Config file at " + configFilePathUsed + " is not in the correct format." + + " Using default config properties."); initializedConfig = new Config(); } @@ -143,21 +146,22 @@ protected Config initConfig(Path configFilePath) { */ protected UserPrefs initPrefs(UserPrefsStorage storage) { Path prefsFilePath = storage.getUserPrefsFilePath(); - logger.info("Using prefs file : " + prefsFilePath); + logger.info("Using preference file : " + prefsFilePath); UserPrefs initializedPrefs; try { Optional prefsOptional = storage.readUserPrefs(); if (!prefsOptional.isPresent()) { - logger.info("Creating new prefs file."); + logger.info("Creating new preference file " + prefsFilePath); } initializedPrefs = prefsOptional.orElse(new UserPrefs()); } catch (DataConversionException e) { - logger.warning("UserPrefs file at " + prefsFilePath + " is not in the correct format. " - + "Using default user prefs"); + logger.warning("Preference file at " + prefsFilePath + " is not in the correct format." + + " Using default preferences."); initializedPrefs = new UserPrefs(); } catch (IOException e) { - logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook"); + logger.warning("Problem while reading from preference file " + prefsFilePath + + ". Will be starting with an empty AddressBook."); initializedPrefs = new UserPrefs(); }