17 static constexpr uint32_t kDefaultReconnectRetries = 4;
18 static constexpr uint32_t kDefaultTimeoutMilliseconds = 250;
22 FTPLogger(uint32_t server_ip_host_ordered, uint16_t server_port_host_ordered,
const std::string& username,
23 const std::string& password, uint32_t timeout_milliseconds)
24 :
FTPLogger(server_ip_host_ordered, server_port_host_ordered, username, password, timeout_milliseconds,
25 kDefaultReconnectRetries) {}
26 FTPLogger(uint32_t server_ip_host_ordered, uint16_t ftp_server_port_host_ordered, std::string username,
27 std::string password, uint32_t timeout_milliseconds, uint32_t reconnect_retries)
28 : ftp_server_ip_{server_ip_host_ordered},
29 ftp_server_port_{ftp_server_port_host_ordered},
30 ftp_user_{std::move(username)},
31 ftp_password_{std::move(password)},
32 ftp_timeout_milliseconds_{timeout_milliseconds},
33 reconnect_retries_{reconnect_retries} {};
40 bool IsConnected()
const;
43 bool WriteFile(
const std::string& filename,
const std::string& content);
45 bool AppendFile(
const std::string& filename,
const std::string& content);
47 bool PutFile(
const std::string& local_filename,
const std::string& remote_filename =
"");
49 void QueuePutFile(
const std::string& local_filename,
const std::string& remote_filename =
"") {
50 send_file_queue_.emplace_back(local_filename, remote_filename);
54 const std::vector<std::pair<std::string, std::string>>
send_file_queue()
const {
return send_file_queue_; }
56 void ClearSendQueue() { send_file_queue_.clear(); }
58 const std::vector<std::string>& error_log()
const {
return error_log_; }
62 void LogError(std::string message);
65 uint32_t ftp_server_ip_;
66 uint16_t ftp_server_port_;
67 std::string ftp_user_;
68 std::string ftp_password_;
69 uint32_t ftp_timeout_milliseconds_;
70 uint32_t reconnect_retries_;
72 FTPClient* ftp_client_{
nullptr};
74 std::vector<std::string> error_log_;
75 std::vector<std::pair<std::string, std::string>> send_file_queue_;
bool WriteFile(const std::string &filename, const std::string &content)
Truncate the remote file with the given name and set its content.
Definition ftp_logger.cpp:75
bool AppendFile(const std::string &filename, const std::string &content)
Append the given content to the remote file with the given name.
Definition ftp_logger.cpp:103
const std::vector< std::pair< std::string, std::string > > send_file_queue() const
(Local path, Remote path) pairs that have been queued for sending.
Definition ftp_logger.h:54