Rust
Rust
Clear the FTP Session Log
See more FTP Examples
Demonstrates the Chilkat Ftp2.ClearSessionLog method, which clears the in-memory FTP protocol log collected while KeepSessionLog is enabled. It takes no arguments.
Background: With session logging on, the
SessionLog accumulates the full FTP command/reply conversation, which is invaluable for diagnosing a failed transfer. Over a long-lived session it grows unbounded, so clearing it frees memory — and, more usefully, lets you capture the log for one specific operation in isolation by clearing just before and reading just after.Chilkat Rust Downloads
// Demonstrates the Ftp2.ClearSessionLog method, which clears the in-memory FTP protocol log. It
// takes no arguments and is a void method.
let ftp = chilkat::Ftp2::new();
ftp.set_hostname("ftp.example.com");
ftp.set_username("myFtpLogin");
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
ftp.set_password("myPassword");
if ftp.connect().is_err() {
println!("{}", ftp.last_error_text());
return;
}
// The SessionLog accumulates the FTP protocol conversation when KeepSessionLog is enabled, which
// is useful for debugging.
ftp.set_keep_session_log(true);
// ... perform some operations ...
// Clear the log, for example before starting a new logical operation whose log you want to
// capture in isolation.
ftp.clear_session_log();
println!("Session log cleared.");
if ftp.disconnect().is_err() {
println!("{}", ftp.last_error_text());
return;
}