I am looking for the best way to log the content of a file when it is created. The process creates a file from some data, and I would like to log the content that has been written to the file.
I perform the following.
with open(file_path, "a") as new_file:
wr = csv.writer(new_file, delimiter=delimiter, quoting=csv.QUOTE_NONE,)
wr.writerows(file_content)
The variable file_content
is a list that is passed to this function.
What I am looking for is that with the logging
module of Python, logging the content of the file. I want to avoid having to read the newly created file in read mode and read the contents. And I want the content of the log to be the plain text as it is written in the file.