Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
[logging] handle exceptions during empty log file removal
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Feb 19, 2016
1 parent d1d48ea commit a9a423b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyemma/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@author: marscher
'''

from __future__ import absolute_import
from __future__ import absolute_import, print_function

import pkg_resources
import logging
Expand Down Expand Up @@ -99,9 +99,14 @@ class LoggingConfigurationError(RuntimeError):
import atexit
@atexit.register
def clean_empty_log_files():
# gracefully shutdown logging system
logging.shutdown()
for f in log_files:
if f is not None and os.stat(f).st_size == 0:
os.remove(f)
try:
os.remove(f)
except OSError as o:
print("during removal of empty logfiles there was a problem: ", o)


def getLogger(name=None):
Expand Down

0 comments on commit a9a423b

Please sign in to comment.