diff --git a/mapsci/__init__.py b/mapsci/__init__.py index 946888d..286b06a 100644 --- a/mapsci/__init__.py +++ b/mapsci/__init__.py @@ -55,6 +55,7 @@ def initiate_logger(console=None, log_file=None, verbose=30): elif console: logger.warning("StreamHandler already exists") elif handler_console == False: + handler_console.close() logger.removeHandler(handler_console) # Rotating File Handler @@ -73,5 +74,6 @@ def initiate_logger(console=None, log_file=None, verbose=30): elif log_file: logger.warning("RotatingFileHandler already exists") elif handler_logfile == False: + handler_logfile.close() logger.removeHandler(handler_logfile) diff --git a/mapsci/tests/test_mapsci.py b/mapsci/tests/test_mapsci.py index 471c503..8e651e6 100644 --- a/mapsci/tests/test_mapsci.py +++ b/mapsci/tests/test_mapsci.py @@ -33,7 +33,10 @@ def test_mapsci_log_file(): if os.path.isfile(fname): flag = True mapsci.initiate_logger(log_file=False) - os.remove(fname) + try: + os.remove(fname) + except: + print("Error removing log file") else: flag = False