Skip to content

Commit

Permalink
Reduce Verbose Logging in Generators
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Feb 15, 2024
1 parent 02dc828 commit bcea4f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ public abstract class AbstractBasicJavaGenerator {
* @param skipsGen Collection of predicates to determine if a function should be skipped when generating code.
* @throws ClassNotFoundException If a class in the imports array cannot be found.
*/
public AbstractBasicJavaGenerator(final String gradleTask, final String packageName, final String className,
final String[] imports, Predicate<Method> includeMethod, Collection<Predicate<JavaFunction>> skipsGen)
public AbstractBasicJavaGenerator(
final String gradleTask,
final String packageName,
final String className,
final String[] imports,
final Predicate<Method> includeMethod,
final Collection<Predicate<JavaFunction>> skipsGen,
final Level logLevel)
throws ClassNotFoundException {
this.gradleTask = gradleTask;
this.packageName = packageName;
this.className = className;
this.skipsGen = skipsGen;

log.setLevel(logLevel);

for (String imp : imports) {
Class<?> c = Class.forName(imp, false, Thread.currentThread().getContextClassLoader());
log.info("Processing class: " + c);
Expand Down Expand Up @@ -158,7 +166,6 @@ public static void runCommandLine(final AbstractBasicJavaGenerator gen, final St
System.exit(-1);
}

log.setLevel(Level.WARNING);
log.warning("Running " + gen.getClass().getSimpleName() + " assertNoChange=" + assertNoChange);

final String code = gen.generateCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.stream.Collectors;


Expand All @@ -25,9 +26,9 @@
public class GroovyStaticImportGenerator extends AbstractBasicJavaGenerator {

public GroovyStaticImportGenerator(String gradleTask, String packageName, String className, String[] imports,
Predicate<Method> includeMethod, Collection<Predicate<JavaFunction>> skipsGen)
Predicate<Method> includeMethod, Collection<Predicate<JavaFunction>> skipsGen, Level logLevel)
throws ClassNotFoundException {
super(gradleTask, packageName, className, imports, includeMethod, skipsGen);
super(gradleTask, packageName, className, imports, includeMethod, skipsGen, logLevel);
}

@Override
Expand Down Expand Up @@ -79,7 +80,8 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio
// skipping common erasure "sum"
Collections.singletonList((f) -> f.getMethodName().equals("sum") && f.getParameterTypes().length == 1
&& f.getParameterTypes()[0].getTypeName()
.contains("ObjectVector<")));
.contains("ObjectVector<")),
Level.WARNING);

runCommandLine(gen, relativeFilePath, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.stream.Collectors;

/**
Expand All @@ -24,8 +25,8 @@ public class StaticCalendarMethodsGenerator extends AbstractBasicJavaGenerator {

public StaticCalendarMethodsGenerator(String gradleTask, String packageName, String className, String[] imports,
Predicate<Method> includeMethod, Collection<Predicate<JavaFunction>> skipsGen,
Function<String, String> renamer) throws ClassNotFoundException {
super(gradleTask, packageName, className, imports, includeMethod, skipsGen);
Function<String, String> renamer, Level logLevel) throws ClassNotFoundException {
super(gradleTask, packageName, className, imports, includeMethod, skipsGen, logLevel);
this.renamer = renamer;
}

Expand Down Expand Up @@ -93,7 +94,8 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio
} else {
return s;
}
});
},
Level.WARNING);

runCommandLine(gen, relativeFilePath, args);
}
Expand Down

0 comments on commit bcea4f8

Please sign in to comment.