java-decompiler: class name logging on non-fatal errors

This commit is contained in:
Roman Shevchenko 2014-10-08 08:18:26 +02:00
parent d96104bdec
commit 1e3d5276a8
3 changed files with 45 additions and 19 deletions

View File

@ -236,6 +236,7 @@ public class ClassesProcessor {
return;
}
DecompilerContext.getLogger().startReadingClass(cl.qualifiedName);
try {
ImportCollector importCollector = new ImportCollector(root);
DecompilerContext.setImportCollector(importCollector);
@ -291,6 +292,7 @@ public class ClassesProcessor {
}
finally {
destroyWrappers(root);
DecompilerContext.getLogger().endReadingClass();
}
}

View File

@ -33,7 +33,7 @@ public class PrintStreamLogger extends IFernflowerLogger {
@Override
public void writeMessage(String message, Severity severity) {
if (accepts(severity)) {
stream.println(InterpreterUtil.getIndentString(indent) + severity.name() + ": " + message);
stream.println(severity.prefix + InterpreterUtil.getIndentString(indent) + message);
}
}
@ -45,36 +45,50 @@ public class PrintStreamLogger extends IFernflowerLogger {
}
}
@Override
public void startReadingClass(String className) {
writeMessage("Decompiling class " + className, Severity.INFO);
++indent;
}
@Override
public void endReadingClass() {
--indent;
writeMessage("... done", Severity.INFO);
}
@Override
public void startClass(String className) {
writeMessage("Processing class " + className + " ...", Severity.INFO);
writeMessage("Processing class " + className, Severity.TRACE);
++indent;
}
@Override
public void endClass() {
--indent;
writeMessage("... proceeded.", Severity.INFO);
writeMessage("... proceeded", Severity.TRACE);
}
@Override
public void startMethod(String methodName) {
writeMessage("Processing method " + methodName, Severity.TRACE);
++indent;
}
public void endMethod() {
--indent;
writeMessage("... proceeded", Severity.TRACE);
}
@Override
public void startWriteClass(String className) {
writeMessage("Writing class " + className + " ...", Severity.INFO);
writeMessage("Writing class " + className, Severity.TRACE);
++indent;
}
@Override
public void endWriteClass() {
--indent;
writeMessage("... written.", Severity.INFO);
}
@Override
public void startMethod(String methodName) {
writeMessage("Processing method " + methodName + " ...", Severity.INFO);
}
public void endMethod() {
writeMessage("... proceeded.", Severity.INFO);
writeMessage("... written", Severity.TRACE);
}
}

View File

@ -18,7 +18,13 @@ package org.jetbrains.java.decompiler.main.extern;
public abstract class IFernflowerLogger {
public enum Severity {
TRACE, INFO, WARN, ERROR
TRACE("TRACE: "), INFO("INFO: "), WARN("WARN: "), ERROR("ERROR: ");
public final String prefix;
Severity(String prefix) {
this.prefix = prefix;
}
}
private Severity severity = Severity.INFO;
@ -35,15 +41,19 @@ public abstract class IFernflowerLogger {
public abstract void writeMessage(String message, Throwable t);
public void startReadingClass(String className) { }
public void endReadingClass() { }
public void startClass(String className) { }
public void endClass() { }
public void startWriteClass(String className) { }
public void endWriteClass() { }
public void startMethod(String methodName) { }
public void endMethod() { }
public void startWriteClass(String className) { }
public void endWriteClass() { }
}