def close(self):
<EOL>if self.closed:<EOL><INDENT>return<EOL><DEDENT>super().close()<EOL>if not self.upload_on_close:<EOL><INDENT>return<EOL><DEDENT>local_loc = os.path.join(self.local_base, self.log_relative_path)<EOL>remote_loc = os.path.join(self.remote_base, self.log_relative_path)<EOL>if os.path.exists(local_loc):<EOL><INDENT>with open(local_loc, '<STR_LIT:r>') as logfile:<EOL><INDENT>log = logfile.read()<EOL><DEDENT>self.s3_write(log, remote_loc)<EOL><DEDENT>self.closed = True<EOL>
Close and upload local log file to remote storage S3.