Skip to content

Commit 1c25749

Browse files
authored
Add optional tracing support to Session drop impl (#164)
* Add optional dependency tracing Signed-off-by: Jiahao XU <[email protected]> * Add logging for <process_mux_impl::Session as Drop>::drop Signed-off-by: Jiahao XU <[email protected]> * Add tracing to <native_mux_impl::Session as Drop>::drop Signed-off-by: Jiahao XU <[email protected]> * Unify drop logging msg Signed-off-by: Jiahao XU <[email protected]> --------- Signed-off-by: Jiahao XU <[email protected]>
1 parent e977789 commit 1c25749

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ openssh-mux-client = { version = "0.17.0", optional = true }
4949

5050
libc = "0.2.137"
5151

52+
tracing = { version = "0.1", optional = true }
53+
5254
[dev-dependencies]
5355
regex = "1"
5456
tokio = { version = "1", features = [ "full" ] }

src/native_mux_impl/session.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ impl Drop for Session {
105105
None => return,
106106
};
107107

108-
let _ = shutdown_mux_master(&self.ctl);
108+
let _res = shutdown_mux_master(&self.ctl);
109+
#[cfg(feature = "tracing")]
110+
if let Err(err) = _res {
111+
tracing::error!("Closing ssh session failed: {}", err);
112+
}
109113
}
110114
}

src/process_impl/session.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,14 @@ impl Drop for Session {
226226
None => return,
227227
};
228228

229-
let _ = self
229+
let _res = self
230230
.new_std_cmd(&["-O", "exit"])
231231
.stdout(Stdio::null())
232232
.stderr(Stdio::null())
233233
.status();
234+
#[cfg(feature = "tracing")]
235+
if let Err(err) = _res {
236+
tracing::error!("Closing ssh session failed: {}", err);
237+
}
234238
}
235239
}

0 commit comments

Comments
 (0)