Skip to content

Commit

Permalink
Add an exception object to the logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii Beliakov committed Aug 16, 2024
1 parent 7a288ed commit c25b0fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jcraft/jsch/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public void connect(int connectTimeout) throws JSchException {
// System.err.println("ee: " + ee);
if (getLogger().isEnabled(Logger.WARN)) {
getLogger().log(Logger.WARN,
"an exception during authentication\n" + Util.getStackTraceAsString(ee));
"an exception during authentication\n" + ee.toString(), ee);
}
break loop;
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/jcraft/jsch/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
Expand Down Expand Up @@ -528,11 +526,4 @@ static String getSystemProperty(String key, String def) {
return def;
}
}

static String getStackTraceAsString(final Throwable throwable) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
return sw.getBuffer().toString();
}
}

0 comments on commit c25b0fa

Please sign in to comment.