logging reworked

- implementation-specific method removed from the API
- internal exceptions handling incapsulated
master
Roman Shevchenko 11 years ago
parent f221cd1c55
commit 25bd28a290
  1. 12
      src/de/fernflower/main/ClassWriter.java
  2. 4
      src/de/fernflower/main/Fernflower.java
  3. 17
      src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java
  4. 5
      src/de/fernflower/main/extern/IFernflowerLogger.java
  5. 12
      src/de/fernflower/main/rels/ClassWrapper.java

@ -637,11 +637,7 @@ public class ClassWriter {
String code = root.toJava(indent+1);
bufstrwriter.write(code);
} catch(Throwable ex) {
if(DecompilerContext.getLogger().getShowStacktrace()) {
ex.printStackTrace();
}
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be written.", IFernflowerLogger.ERROR);
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be written.", ex);
meth.decompiledWithErrors = true;
}
}
@ -978,11 +974,7 @@ public class ClassWriter {
bufstrwriter.write(code);
} catch(Throwable ex) {
if(DecompilerContext.getLogger().getShowStacktrace()) {
ex.printStackTrace();
}
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be written.", IFernflowerLogger.ERROR);
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be written.", ex);
meth.decompiledWithErrors = true;
}
}

@ -22,7 +22,6 @@ import de.fernflower.main.ClassesProcessor.ClassNode;
import de.fernflower.main.collectors.CounterContainer;
import de.fernflower.main.extern.IBytecodeProvider;
import de.fernflower.main.extern.IDecompilatSaver;
import de.fernflower.main.extern.IFernflowerLogger;
import de.fernflower.main.extern.IFernflowerPreferences;
import de.fernflower.modules.renamer.IdentifierConverter;
import de.fernflower.struct.IDecompiledData;
@ -98,8 +97,7 @@ public class Fernflower implements IDecompiledData {
} catch(ThreadDeath ex) {
throw ex;
} catch(Throwable ex) {
ex.printStackTrace();
DecompilerContext.getLogger().writeMessage("Class "+cl.qualifiedName+" couldn't be fully decompiled." , IFernflowerLogger.ERROR);
DecompilerContext.getLogger().writeMessage("Class "+cl.qualifiedName+" couldn't be fully decompiled.", ex);
}
return res;

@ -35,14 +35,15 @@ public class PrintStreamLogger implements IFernflowerLogger {
public void writeMessage(String message, int severity) {
writeMessage(message, severity, indent);
if(severity >= this.severity) {
stream.println(InterpreterUtil.getIndentString(indent)+names[severity]+": "+message);
}
}
public void writeMessage(String message, int severity, int indent) {
if(severity >= this.severity) {
stream.println(InterpreterUtil.getIndentString(indent)+names[severity]+": "+message);
}
}
public void writeMessage(String message, Throwable t) {
t.printStackTrace(stream);
writeMessage(message, ERROR);
}
public void startClass(String classname) {
stream.println(InterpreterUtil.getIndentString(indent++)+"Processing class "+classname+" ...");
@ -79,8 +80,4 @@ public class PrintStreamLogger implements IFernflowerLogger {
public void setSeverity(int severity) {
this.severity = severity;
}
public boolean getShowStacktrace() {
return true;
}
}

@ -36,7 +36,7 @@ public interface IFernflowerLogger {
public void writeMessage(String message, int severity);
public void writeMessage(String message, int severity, int indent);
public void writeMessage(String message, Throwable t);
public void startClass(String classname);
@ -53,7 +53,4 @@ public interface IFernflowerLogger {
public int getSeverity();
public void setSeverity(int severity);
public boolean getShowStacktrace();
}

@ -110,7 +110,7 @@ public class ClassWrapper {
if(maxsec > 0 && ++sec > maxsec) {
DecompilerContext.getLogger().writeMessage("Processing time limit ("+maxsec+" sec.) for method " +
mt.getName()+" "+mt.getDescriptor()+ " exceeded, execution interrupted.", IFernflowerLogger.ERROR, 0);
mt.getName()+" "+mt.getDescriptor()+ " exceeded, execution interrupted.", IFernflowerLogger.ERROR);
mtthread.stop();
isError = true;
break;
@ -158,17 +158,11 @@ public class ClassWrapper {
if(mtthread != null) {
mtthread.stop();
}
} catch(Throwable e) {
;
}
} catch(Throwable ignored) { }
throw ex;
} catch(Throwable ex) {
if(DecompilerContext.getLogger().getShowStacktrace()) {
ex.printStackTrace();
}
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be decompiled.", IFernflowerLogger.ERROR);
DecompilerContext.getLogger().writeMessage("Method "+mt.getName()+" "+mt.getDescriptor()+" couldn't be decompiled.", ex);
isError = true;
}

Loading…
Cancel
Save