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

feat: improve logging for refactoring #236

Merged
merged 1 commit into from
Oct 27, 2022
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package xyz.keksdose.spoon.code_solver.history;

import com.google.common.flogger.FluentLogger;
import java.util.HashSet;
import java.util.Set;
import spoon.reflect.declaration.CtType;

public class ChangeListener {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private boolean changed;
private Set<CtType<?>> changedTypes = new HashSet<>();
private Changelog changelog = new Changelog();
Expand All @@ -19,6 +21,7 @@ public void reset() {
}

public void setChanged(CtType<?> changedType, Change change) {
logger.atInfo().log("Type %s changed", changedType.getQualifiedName());
changed = true;
changedTypes.add(changedType);
changelog.addChange(change);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public void printChangedTypes(ChangeListener listener, Iterable<CtType<?>> newTy
continue;
}
try {
logger.atInfo().log("Writing file %s", type.getQualifiedName());
Files.writeString(type.getPosition().getFile().toPath(), prettyPrinter.printTypes(type));
} catch (Throwable e) {
logger.atSevere().withCause(e).log("Could not write file %s", type.getQualifiedName());
Expand Down