File size: 1,148 Bytes
dbd79bd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# - x - x - x - x - x - x - x - x - x - x - x - x - x - x - #
# #
# This file was created by: Alberto Palomo Alonso #
# Universidad de Alcalá - Escuela Politécnica Superior #
# #
# - x - x - x - x - x - x - x - x - x - x - x - x - x - x - #
# Import statements:
import os
import shutil
import logging
# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
def clear_logs(log_path: str):
"""
Clears all the files inside log_path path.
Args:
log_path (str): The file path to be clean.
Raises:
ValueError: If the log_path is not valid.
"""
# Close all loggers:
logging.getLogger().handlers.clear()
if os.path.exists(log_path):
# Clear the directory if it exists
shutil.rmtree(log_path)
else:
raise ValueError(f'Path {log_path} does not exist.')
# - x - x - x - x - x - x - x - x - x - x - x - x - x - x - #
# END OF FILE #
# - x - x - x - x - x - x - x - x - x - x - x - x - x - x - #
|