aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/utils/logging.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-10-02 20:32:32 +0800
committerAaron LI <aaronly.me@outlook.com>2016-10-02 20:32:32 +0800
commitd5dcd64ed8bf95adfd08451f26338ed920e7b8e1 (patch)
tree56209283fc2c8bfbe235b9a6ba9a7c20cef73cf5 /fg21sim/utils/logging.py
parentc9a0ad9acd536524d7d6c527f9c7bd171446da57 (diff)
downloadfg21sim-d5dcd64ed8bf95adfd08451f26338ed920e7b8e1.tar.bz2
utils/logging.py: Close handler before removing
Diffstat (limited to 'fg21sim/utils/logging.py')
-rw-r--r--fg21sim/utils/logging.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/fg21sim/utils/logging.py b/fg21sim/utils/logging.py
index df0a4df..bc827fc 100644
--- a/fg21sim/utils/logging.py
+++ b/fg21sim/utils/logging.py
@@ -48,6 +48,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None):
# Clear existing handlers, otherwise further "basicConfig" calls
# will be ignored
for handler in root_logger.handlers:
+ handler.close()
root_logger.removeHandler(handler)
# Initialize/reconfigure the logging, which will automatically
# create a ``Formatter`` for handlers if necessary, and adding
@@ -69,6 +70,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None):
for handler in root_logger.handlers:
if isinstance(handler, StreamHandler):
# remove old ``StreamHandler``
+ handler.close()
root_logger.removeHandler(handler)
if stream == "":
# disable ``StreamHandler``
@@ -86,6 +88,7 @@ def setup_logging(dict_config=None, level=None, stream=None, logfile=None):
if isinstance(handler, FileHandler):
filemode = handler.mode
# remove old ``FileHandler``
+ handler.close()
root_logger.removeHandler(handler)
if logfile == "":
# disable ``FileHandler``