summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-05-26 21:47:04 +0400
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-05-26 21:47:04 +0400
commit25bd28a290170260865e2ca07565cf096bc4e7d3 (patch)
treea9da4a87b7fc63b65af79adfa635bb912c3c1e15 /src
parentf221cd1c554f42873f4a3b2230d56aaf0bfbbb78 (diff)
downloadfernflower-25bd28a290170260865e2ca07565cf096bc4e7d3.tar
fernflower-25bd28a290170260865e2ca07565cf096bc4e7d3.tar.gz
fernflower-25bd28a290170260865e2ca07565cf096bc4e7d3.tar.lz
fernflower-25bd28a290170260865e2ca07565cf096bc4e7d3.tar.xz
fernflower-25bd28a290170260865e2ca07565cf096bc4e7d3.zip
logging reworked
- implementation-specific method removed from the API - internal exceptions handling incapsulated
Diffstat (limited to 'src')
-rw-r--r--src/de/fernflower/main/ClassWriter.java12
-rw-r--r--src/de/fernflower/main/Fernflower.java4
-rw-r--r--src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java19
-rw-r--r--src/de/fernflower/main/extern/IFernflowerLogger.java5
-rw-r--r--src/de/fernflower/main/rels/ClassWrapper.java12
5 files changed, 15 insertions, 37 deletions
diff --git a/src/de/fernflower/main/ClassWriter.java b/src/de/fernflower/main/ClassWriter.java
index e0684ba..9f52dda 100644
--- a/src/de/fernflower/main/ClassWriter.java
+++ b/src/de/fernflower/main/ClassWriter.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;
}
}
diff --git a/src/de/fernflower/main/Fernflower.java b/src/de/fernflower/main/Fernflower.java
index 2c594f0..a712450 100644
--- a/src/de/fernflower/main/Fernflower.java
+++ b/src/de/fernflower/main/Fernflower.java
@@ -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;
diff --git a/src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java b/src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java
index 6424b10..7d1de7d 100644
--- a/src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java
+++ b/src/de/fernflower/main/decompiler/helper/PrintStreamLogger.java
@@ -35,15 +35,16 @@ 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;
- }
}
diff --git a/src/de/fernflower/main/extern/IFernflowerLogger.java b/src/de/fernflower/main/extern/IFernflowerLogger.java
index 3c5543e..c33ce50 100644
--- a/src/de/fernflower/main/extern/IFernflowerLogger.java
+++ b/src/de/fernflower/main/extern/IFernflowerLogger.java
@@ -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();
-
}
diff --git a/src/de/fernflower/main/rels/ClassWrapper.java b/src/de/fernflower/main/rels/ClassWrapper.java
index 80eb5c7..11adda0 100644
--- a/src/de/fernflower/main/rels/ClassWrapper.java
+++ b/src/de/fernflower/main/rels/ClassWrapper.java
@@ -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;
}