Skip to content

Commit

Permalink
feat: improve logging for refactoring (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Oct 27, 2022
1 parent 670338b commit 7538085
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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

0 comments on commit 7538085

Please sign in to comment.