Skip to content

Commit

Permalink
Make file-related log messages more informative
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Eclipse-Dominator authored and damithc committed May 18, 2023
1 parent 4acffdd commit a3f7c82
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -118,12 +121,12 @@ protected Config initConfig(Path configFilePath) {
try {
Optional<Config> 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();
}

Expand All @@ -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<UserPrefs> 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();
}

Expand Down

0 comments on commit a3f7c82

Please sign in to comment.