Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging #106

Merged
merged 4 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/seedu/teachstack/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

@Override
public void init() throws Exception {
logger.info("=============================[ Initializing AddressBook ]===========================");
logger.info("=============================[ Initializing TeachStack ]===========================");

Check warning on line 51 in src/main/java/seedu/teachstack/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/teachstack/MainApp.java#L51

Added line #L51 was not covered by tests
super.init();

AppParameters appParameters = AppParameters.parse(getParameters());
Expand Down Expand Up @@ -81,12 +81,12 @@
addressBookOptional = storage.readAddressBook();
if (!addressBookOptional.isPresent()) {
logger.info("Creating a new data file " + storage.getAddressBookFilePath()
+ " populated with a sample AddressBook.");
+ " populated with sample TeachStack data.");
}
initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
} catch (DataLoadingException e) {
logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded."
+ " Will be starting with an empty AddressBook.");
+ " Will be starting with an empty TeachStack.");
initialData = new AddressBook();
}

Expand Down Expand Up @@ -170,13 +170,13 @@

@Override
public void start(Stage primaryStage) {
logger.info("Starting AddressBook " + MainApp.VERSION);
logger.info("Starting TeachStack " + MainApp.VERSION);

Check warning on line 173 in src/main/java/seedu/teachstack/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/teachstack/MainApp.java#L173

Added line #L173 was not covered by tests
ui.start(primaryStage);
}

@Override
public void stop() {
logger.info("============================ [ Stopping Address Book ] =============================");
logger.info("============================ [ Stopping TeachStack ] =============================");

Check warning on line 179 in src/main/java/seedu/teachstack/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/teachstack/MainApp.java#L179

Added line #L179 was not covered by tests
try {
storage.saveUserPrefs(model.getUserPrefs());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";
public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting TeachStack as requested ...";

@Override
public CommandResult execute(Model model) {
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/seedu/teachstack/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;

import seedu.teachstack.commons.core.LogsCenter;
import seedu.teachstack.commons.core.index.Index;
import seedu.teachstack.commons.util.StringUtil;
import seedu.teachstack.logic.parser.exceptions.ParseException;
Expand All @@ -21,6 +23,8 @@
public class ParserUtil {

public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer.";
private static final Logger logger = LogsCenter.getLogger(ParserUtil.class);


/**
* Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be
Expand All @@ -29,6 +33,7 @@ public class ParserUtil {
*/
public static Index parseIndex(String oneBasedIndex) throws ParseException {
String trimmedIndex = oneBasedIndex.trim();
log(trimmedIndex);
if (!StringUtil.isNonZeroUnsignedInteger(trimmedIndex)) {
throw new ParseException(MESSAGE_INVALID_INDEX);
}
Expand All @@ -44,6 +49,7 @@ public static Index parseIndex(String oneBasedIndex) throws ParseException {
public static StudentId parseStudentId(String studentId) throws ParseException {
requireNonNull(studentId);
String trimmedStudentId = studentId.trim();
log(trimmedStudentId);
if (!StudentId.isValidStudentId(trimmedStudentId)) {
throw new ParseException(StudentId.MESSAGE_CONSTRAINTS);
}
Expand All @@ -59,27 +65,13 @@ public static StudentId parseStudentId(String studentId) throws ParseException {
public static Name parseName(String name) throws ParseException {
requireNonNull(name);
String trimmedName = name.trim();
log(trimmedName);
if (!Name.isValidName(trimmedName)) {
throw new ParseException(Name.MESSAGE_CONSTRAINTS);
}
return new Name(trimmedName);
}
















/**
* Parses a {@code String email} into an {@code Email}.
* Leading and trailing whitespaces will be trimmed.
Expand All @@ -89,6 +81,7 @@ public static Name parseName(String name) throws ParseException {
public static Email parseEmail(String email) throws ParseException {
requireNonNull(email);
String trimmedEmail = email.trim();
log(trimmedEmail);
if (!Email.isValidEmail(trimmedEmail)) {
throw new ParseException(Email.MESSAGE_CONSTRAINTS);
}
Expand All @@ -104,6 +97,7 @@ public static Email parseEmail(String email) throws ParseException {
public static Grade parseGrade(String grade) throws ParseException {
requireNonNull(grade);
String trimmedGrade = grade.trim();
log(trimmedGrade);
if (!Grade.isValidGrade(trimmedGrade)) {
throw new ParseException(Grade.MESSAGE_CONSTRAINTS);
}
Expand All @@ -119,6 +113,7 @@ public static Grade parseGrade(String grade) throws ParseException {
public static Group parseGroup(String group) throws ParseException {
requireNonNull(group);
String trimmedGroup = group.trim();
log(trimmedGroup);
if (!Group.isValidGroupName(trimmedGroup)) {
throw new ParseException(Group.MESSAGE_CONSTRAINTS);
}
Expand Down Expand Up @@ -150,5 +145,9 @@ public static Set<StudentId> parseStudentIds(Collection<String> studentIds) thro
return studentIdSet;
}

private static void log(String argument) {
logger.fine("----------------[ARGUMENT][" + argument + "]");
}


}
Loading