Skip to content

Commit

Permalink
Use a logging framework
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed Jan 11, 2017
1 parent a9bed14 commit 4bb6440
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .idea/libraries/Maven__com_esotericsoftware_minlog_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@
<version>2.6</version>
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>minlog</artifactId>
<version>1.3</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
1 change: 1 addition & 0 deletions retrolambda-maven-plugin/retrolambda-maven-plugin.iml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="retrolambda" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-debug-all:5.2" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware:minlog:1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.maven:maven-plugin-api:2.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.maven.plugin-tools:maven-plugin-annotations:3.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.maven:maven-artifact:3.0" level="project" />
Expand Down
15 changes: 15 additions & 0 deletions retrolambda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>minlog</artifactId>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -99,6 +104,10 @@
<pattern>com.google</pattern>
<shadedPattern>net.orfjackal.retrolambda.google</shadedPattern>
</relocation>
<relocation>
<pattern>com.esotericsoftware.minlog</pattern>
<shadedPattern>net.orfjackal.retrolambda.minlog</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
Expand All @@ -115,6 +124,12 @@
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.esotericsoftware:minlog</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions retrolambda/retrolambda.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm-debug-all:5.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
<orderEntry type="library" name="Maven: com.esotericsoftware:minlog:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
Expand Down
9 changes: 5 additions & 4 deletions retrolambda/src/main/java/net/orfjackal/retrolambda/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net>
// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda;

import com.esotericsoftware.minlog.Log;

import java.io.*;
import java.util.Properties;

Expand All @@ -13,7 +15,7 @@ public static void main(String[] args) {
System.out.println("Retrolambda " + getVersion());

if (!isRunningJava8()) {
System.out.println("Error! Not running under Java 8");
Log.error("Not running under Java 8");
System.exit(1);
}

Expand All @@ -25,8 +27,7 @@ public static void main(String[] args) {
try {
Retrolambda.run(config);
} catch (Throwable t) {
System.out.println("Error! Failed to run Retrolambda");
t.printStackTrace(System.out);
Log.error("Failed to run Retrolambda", t);
System.exit(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net>
// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda;

import com.esotericsoftware.minlog.Log;
import net.orfjackal.retrolambda.files.*;
import net.orfjackal.retrolambda.interfaces.*;
import net.orfjackal.retrolambda.lambdas.*;
Expand All @@ -23,16 +24,16 @@ public static void run(Config config) throws Throwable {
Path outputDir = config.getOutputDir();
List<Path> classpath = config.getClasspath();
List<Path> includedFiles = config.getIncludedFiles();
System.out.println("Bytecode version: " + bytecodeVersion + " (" + Bytecode.getJavaVersion(bytecodeVersion) + ")");
System.out.println("Default methods: " + defaultMethodsEnabled);
System.out.println("Input directory: " + inputDir);
System.out.println("Output directory: " + outputDir);
System.out.println("Classpath: " + classpath);
System.out.println("Included files: " + (includedFiles != null ? includedFiles.size() : "all"));
System.out.println("Agent enabled: " + PreMain.isAgentLoaded());
Log.info("Bytecode version: " + bytecodeVersion + " (" + Bytecode.getJavaVersion(bytecodeVersion) + ")");
Log.info("Default methods: " + defaultMethodsEnabled);
Log.info("Input directory: " + inputDir);
Log.info("Output directory: " + outputDir);
Log.info("Classpath: " + classpath);
Log.info("Included files: " + (includedFiles != null ? includedFiles.size() : "all"));
Log.info("Agent enabled: " + PreMain.isAgentLoaded());

if (!Files.isDirectory(inputDir)) {
System.out.println("Nothing to do; not a directory: " + inputDir);
Log.info("Nothing to do; not a directory: " + inputDir);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net>
// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda.interfaces;

import com.esotericsoftware.minlog.Log;
import org.objectweb.asm.*;

import static net.orfjackal.retrolambda.util.Flags.*;
Expand Down Expand Up @@ -47,7 +48,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
}

private void printWarning(String methodKind, String methodName) {
System.out.println("WARNING: The interface " + interfaceName + " has " + methodKind + " \"" + methodName + "\" " +
Log.warn("The interface " + interfaceName + " has " + methodKind + " \"" + methodName + "\" " +
"but backporting default methods is not enabled");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package net.orfjackal.retrolambda.lambdas;

import com.esotericsoftware.minlog.Log;
import net.orfjackal.retrolambda.interfaces.*;
import net.orfjackal.retrolambda.util.Bytecode;
import org.objectweb.asm.*;
Expand Down Expand Up @@ -42,10 +43,8 @@ private static void resetLambdaClassSequenceNumber() {
AtomicInteger counter = (AtomicInteger) counterField.get(null);
counter.set(0);
} catch (Throwable t) {
// print to stdout to keep in sync with other log output
System.out.println("WARNING: Failed to start class numbering from one. Don't worry, it's cosmetic, " +
"but please file a bug report and tell on which JDK version this happened.");
t.printStackTrace(System.out);
Log.warn("Failed to start class numbering from one. Don't worry, it's cosmetic, " +
"but please file a bug report and tell on which JDK version this happened.", t);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright © 2013-2015 Esko Luontola <www.orfjackal.net>
// Copyright © 2013-2017 Esko Luontola and other Retrolambda contributors
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda.lambdas;

import com.esotericsoftware.minlog.Log;
import net.orfjackal.retrolambda.Transformers;
import net.orfjackal.retrolambda.files.OutputDirectory;
import org.objectweb.asm.ClassReader;
Expand All @@ -27,7 +28,7 @@ public void saveIfLambda(String className, byte[] bytecode) {
}

private void reifyLambdaClass(String className, byte[] bytecode) {
System.out.println("Saving lambda class: " + className);
Log.info("Saving lambda class: " + className);
bytecode = transformers.backportLambdaClass(new ClassReader(bytecode));
try {
saver.writeClass(bytecode);
Expand Down

0 comments on commit 4bb6440

Please sign in to comment.