Skip to content

Commit

Permalink
Make file-creation logs not resemble errors
Browse files Browse the repository at this point in the history
At the first run, any missing data/config files are created
with a 'file not found' log message, which might alarm the user
as it looks like an error message.

Let's tweak the log messages to not resemble error messages.
  • Loading branch information
LimJunxue authored and damithc committed May 18, 2023
1 parent 1e05fef commit 4acffdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
try {
addressBookOptional = storage.readAddressBook();
if (!addressBookOptional.isPresent()) {
logger.info("Data file not found. Will be starting with a sample AddressBook");
logger.info("Creating a new data file populated with a sample AddressBook");
}
initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
} catch (DataConversionException e) {
Expand Down Expand Up @@ -117,6 +117,9 @@ protected Config initConfig(Path configFilePath) {

try {
Optional<Config> configOptional = ConfigUtil.readConfig(configFilePathUsed);
if (!configOptional.isPresent()) {
logger.info("Creating new 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("Creating new 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 4acffdd

Please sign in to comment.