Skip to content

Commit

Permalink
Add examples of lower-level log messages
Browse files Browse the repository at this point in the history
Let's add a few examples of lower-level log messages, to illustrate to
developers how they can be used in this codebase.
  • Loading branch information
Eclipse-Dominator committed Aug 7, 2023
1 parent a976ec9 commit c00861b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public void init() throws Exception {
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
logger.info("Using data file : " + storage.getAddressBookFilePath());

Optional<ReadOnlyAddressBook> addressBookOptional;
ReadOnlyAddressBook initialData;
try {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;

import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
Expand All @@ -26,6 +28,7 @@ public class AddressBookParser {
* Used for initial separation of command word and args.
*/
private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?<commandWord>\\S+)(?<arguments>.*)");
private static final Logger logger = LogsCenter.getLogger(AddressBookParser.class);

/**
* Parses user input into command for execution.
Expand All @@ -42,6 +45,12 @@ public Command parseCommand(String userInput) throws ParseException {

final String commandWord = matcher.group("commandWord");
final String arguments = matcher.group("arguments");

// Note to developers: Change the log level in config.json to enable lower level (i.e., FINE and lower)
// log messages such as the one below.
// Currently, lower level log messages are used sparingly, to minimize noise in the code.
logger.fine("Command word: " + commandWord + " ; Arguments: " + arguments);

switch (commandWord) {

case AddCommand.COMMAND_WORD:
Expand Down Expand Up @@ -69,6 +78,7 @@ public Command parseCommand(String userInput) throws ParseException {
return new HelpCommand();

default:
logger.finer("This user input caused a ParseException: " + userInput);
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
}
Expand Down

0 comments on commit c00861b

Please sign in to comment.