Skip to content

Commit

Permalink
Add verbose logging support for SshExec
Browse files Browse the repository at this point in the history
  • Loading branch information
jjlauer committed Nov 8, 2023
1 parent a5c6138 commit c1cdbe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void stop() {
if (!this.environment.isEmpty()) {
env = " with env " + this.environment;
}
log.verbose("Exec: [{}]{}{}", cmd, workingDir, env);
log.verbose("Exec [{}]{}{}", cmd, workingDir, env);
}

executor
Expand Down
15 changes: 13 additions & 2 deletions blaze-ssh/src/main/java/com/fizzed/blaze/ssh/impl/JschExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fizzed.blaze.core.UnexpectedExitValueException;
import com.fizzed.blaze.core.BlazeException;
import com.fizzed.blaze.system.Exec;
import com.fizzed.blaze.util.CommandLines;
import com.fizzed.blaze.util.ObjectHelper;
import com.fizzed.blaze.util.WrappedOutputStream;
import com.jcraft.jsch.ChannelExec;
Expand Down Expand Up @@ -165,8 +166,18 @@ public void close() throws IOException {
});

String finalCommand = sb.toString();

log.debug("ssh-exec [{}]", finalCommand);

if (log.isVerbose()) {
String workingDir = "";
String env = "";
if (this.workingDirectory != null) {
workingDir = " in working dir [" + this.workingDirectory + "]";
}
if (!this.environment.isEmpty()) {
env = " with env " + this.environment;
}
log.verbose("SshExec [{}]{}{}", finalCommand, workingDir, env);
}

channel.setCommand(finalCommand);

Expand Down

0 comments on commit c1cdbe2

Please sign in to comment.