# --------------------------------------
# Start of logging of removed folders
# ----------------------------------------
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='RemovedCRMFolders.log',
filemode='w')
# -------------------------------------------
# Checks to see if listed folders exists and then deletes
# -------------------------------------------
def remove_directory(pathslist):
for path in pathslist:
if os.path.exists(path) and os.path.isdir(path):
shutil.rmtree(path)
logging.warning('Found ' + path + ' removing')
print(colored('Found ' + path + ' removing', 'green'))
else:
print('Looking for ' + path + ' not found..')
dirs_to_delete = [
'C:\Folder1',
'C:\Folder2'
]
would using both the logging.warning and print underneath be a way to still show the output in console/window if it finds a folder? Right now if you write the code without print and just logging.warning it will no longer print to console stating it sees the folder and will just write to the log file and I am looking to have it show in console and still print to log is there a easier way to do this within the logging command or is this the best way?