tech.harmonysoft.oss.traute.javac.log.CompilerOutputLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of traute-javac Show documentation
Show all versions of traute-javac Show documentation
A Javac plugin which inserts null-checks into generated bytecode
package tech.harmonysoft.oss.traute.javac.log;
import com.sun.tools.javac.util.Log;
import org.jetbrains.annotations.NotNull;
import tech.harmonysoft.oss.traute.common.util.TrauteConstants;
import javax.tools.JavaCompiler;
/**
* Custom wrapper around standard {@link JavaCompiler javac} {@link Log logger}.
*/
public class CompilerOutputLogger extends AbstractLogger {
private static final String NOTICE_PREFIX = String.format("[%s javac plugin]: ", TrauteConstants.PLUGIN_NAME);
@NotNull private final Log log;
public CompilerOutputLogger(@NotNull Log log) {
this.log = log;
}
@Override
@NotNull
public Log getKey() {
return log;
}
@Override
public void info(@NotNull String message) {
log.printRawLines(Log.WriterKind.NOTICE, NOTICE_PREFIX + message);
}
@Override
public void warn(@NotNull String message) {
log.rawWarning(-1, message);
}
}