loris_log.ftpClient

The library to push log message to FTP server.

class FtpClient:

Class to establish connection and writing to FTP server.

FtpClient(hostname, port_num, username, password)

Establish communication with the remote FTP server.

Args:

hostname (string): FTP server hostname.
port_num (integer): FTP server port number.
username (string): FTP server username.
password (string): FTP server password.

Raise InvalidFTPPortNumberException:

If the port number is not of type int and is equal or less
than zero.

Raise InvalidFTPUserNameException:

If the username is not of type string or it is an empty 
string or it is a None value.

Raise InvalidFTPPasswordException:

If the password is not of type string or it is an empty
string or it is a None value.

Raise FTPConnectionFailedException:

If the connection to the FTP remote server was not 
a success.

Raise InvalidFTPHostNameException:

If any of the port number, username, and password
are invalid.
def create_ftp_log_data(self, directory_path, file_name):

Create a csv log file inside a FTP server based on the predefined path.

Args:

directory_path (string): The path to the csv log file.
file_name (string): Filename of the csv log file.

Raise FTPFileCreationException:

If the filename and directory path are invalid, a None value
or is empty, or is unable to write to a log file in the
FTP server.
def set_ftp_log_data(self, directory_path, file_name, log_data):

Set the csv log file with the desired log data. The new log data will continue log onto the existing file, if the log file was present. Otherwise, new file gonna be created for this new log data. Please do take note that the file type must be of csv type.

Args:

directory_path (string): The path to the csv log file.
file_name (string): The name of the csv log file.
log_data (bytes): The log data.

Raise NoneValueException:

If the directory path, file name or the data to be logged
is of None value.

Raise InvalidAttributeException:

If the directory path, file name is not the type of string,
while the log data is not type of byte.

Raise EmptyParameterException:

If the directory path, file name or log data is empty.
def create_ftp_log_file(self, directory_path, file_name):

Create the log file inside an FTP server.

Args:

directory_name (string): The path to the created log
                            file.
file_name (string): The name of the log file.

Raise FTPFileCreationException:

If the file name or directory path is empty, a none value, is not
of the type string, or is failed to write the log onto the FTP server.
def set_ftp_log_file(self, directory_path, file_name, message):

Set the log file with application or system log. If the log file was already existed, the new log will continue appended on to the existing log file. Otherwise, new log file gonna be created.

Args:

directory_path (string): The path to the log file.
file_name (string): The log file name.
message (string): The log message.

Raise NoneValueException:

If the directory path and file name is a type None.

Raise InvalidAttributeException:

If the directory path, file name or log message is
not the type string.

Raise EmptyParameterException:

If the directory path, file name or log message is
not empty.