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

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

@ -35,15 +35,16 @@ public class PrintStreamLogger implements IFernflowerLogger {
public void writeMessage(String message, int severity) { public void writeMessage(String message, int severity) {
writeMessage(message, severity, indent);
}
public void writeMessage(String message, int severity, int indent) {
if(severity >= this.severity) { if(severity >= this.severity) {
stream.println(InterpreterUtil.getIndentString(indent)+names[severity]+": "+message); 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) { public void startClass(String classname) {
stream.println(InterpreterUtil.getIndentString(indent++)+"Processing class "+classname+" ..."); stream.println(InterpreterUtil.getIndentString(indent++)+"Processing class "+classname+" ...");
} }
@ -79,8 +80,4 @@ public class PrintStreamLogger implements IFernflowerLogger {
public void setSeverity(int severity) { public void setSeverity(int severity) {
this.severity = 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);
public void writeMessage(String message, int severity, int indent); public void writeMessage(String message, Throwable t);
public void startClass(String classname); public void startClass(String classname);
@ -53,7 +53,4 @@ public interface IFernflowerLogger {
public int getSeverity(); public int getSeverity();
public void setSeverity(int severity); public void setSeverity(int severity);
public boolean getShowStacktrace();
} }

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

Loading…
Cancel
Save