In the case that it is in the same script log file gets written and you want to remove the original log file retaining only the compressed one, do (the files are available as pathlib path objects). For the set up of the logger see the other post.
Please be aware that copy and paste of the code below will most probably lead to indention error, as the code was more or less just a copy of respective passages in real code.
# Doing some log file handling so the file handler of the logger better
# be removed. Explicit close is required. Othe wise the file does not
# get released causing (on Windows) 'PermissionError: [WinError 32]'
logHandlerFile.close()
logger.removeHandler(logHandlerFile)
createLZMACompressedFile(fileNameIn = str(logFile),
fileNameOut = str(logFileNew),
logger = logger,
removeIn = True)
Keine Kommentare:
Kommentar veröffentlichen