Skip to content

Commit

Permalink
Remove logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
tingxuanp committed Oct 26, 2024
1 parent c24d964 commit 2a0d378
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static java.util.Objects.requireNonNull;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.ToStringBuilder;
Expand Down Expand Up @@ -33,9 +31,7 @@ public class UnassignVendorCommand extends Command {
+ "as it still has a task.";

public static final String MESSAGE_UNASSIGN_VENDOR_FAILURE_NOT_VENDOR = "%1$s is not a vendor.";

private static final Logger logger = Logger.getLogger("Foo");


private final Index targetIndex;

/**
Expand All @@ -49,34 +45,27 @@ public UnassignVendorCommand(Index targetIndex) {

@Override
public CommandResult execute(Model model) throws CommandException {
logger.log(Level.INFO, "Executing UnassignVendorCommand with index: {0}", targetIndex);

requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();

logger.log(Level.INFO, "Validating index: {0}", targetIndex);
if (targetIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToUnassign = lastShownList.get(targetIndex.getZeroBased());
logger.log(Level.INFO, "Attempting to unassign person: {0}", personToUnassign.getName());
assert personToUnassign != null : "Person to unassign must not be null";


// need to change to check if model has the vendor already existing
if (!model.hasVendor(personToUnassign)) {
logger.log(Level.WARNING, "Cannot unassign {0}: not a vendor.", personToUnassign.getName());
throw new CommandException(String.format(MESSAGE_UNASSIGN_VENDOR_FAILURE_NOT_VENDOR,
personToUnassign.getName()));
}

logger.log(Level.INFO, "Unassigning vendor: {0}", personToUnassign.getName());
model.unassignVendor(personToUnassign);
assert !model.hasVendor(personToUnassign) : "Vendor was not unassigned correctly";

logger.log(Level.INFO, "Successfully unassigned vendor: {0}", personToUnassign.getName());
logger.log(Level.INFO, "Finished executing UnassignVendorCommand for index: {0}", targetIndex);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(personToUnassign)));
}

Expand Down

0 comments on commit 2a0d378

Please sign in to comment.