Skip to content

Commit

Permalink
Add logs for creation and discovery of default files
Browse files Browse the repository at this point in the history
As 'file not found' logs may be interpreted
as errors, let's add logs for the creation and discovery of
new default config and prefs files.
  • Loading branch information
LimJunxue authored and Eclipse-Dominator committed May 12, 2023
1 parent f0c6861 commit 6fc857a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ protected Config initConfig(Path configFilePath) {

try {
Optional<Config> configOptional = ConfigUtil.readConfig(configFilePathUsed);
if (!configOptional.isPresent()) {
logger.info("Config file not found. Will be starting with a new default config file.");
}
initializedConfig = configOptional.orElse(new Config());
} catch (DataConversionException e) {
logger.warning("Config file at " + configFilePathUsed + " is not in the correct format. "
Expand Down Expand Up @@ -145,6 +148,9 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {
UserPrefs initializedPrefs;
try {
Optional<UserPrefs> prefsOptional = storage.readUserPrefs();
if (!prefsOptional.isPresent()) {
logger.info("Prefs file not found. Will be starting with a new default prefs file.");
}
initializedPrefs = prefsOptional.orElse(new UserPrefs());
} catch (DataConversionException e) {
logger.warning("UserPrefs file at " + prefsFilePath + " is not in the correct format. "
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/commons/util/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public static <T> Optional<T> readJsonFile(
requireNonNull(filePath);

if (!Files.exists(filePath)) {
logger.info("Json file " + filePath + " not found");
return Optional.empty();
}
logger.info("JSON file " + filePath + " found");

T jsonFile;

Expand Down

0 comments on commit 6fc857a

Please sign in to comment.