Skip to content

Commit

Permalink
Merge pull request #1522 from robotframework/issue/1520/unique-log-fi…
Browse files Browse the repository at this point in the history
…le-names

Create ride.log with unique identifier
  • Loading branch information
yanne committed Sep 14, 2015
2 parents 31dcd6a + a19f43d commit c689879
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/robotide/log/log.py
Expand Up @@ -15,7 +15,9 @@
import wx
import os
import tempfile
import uuid
import atexit
import glob

from robotide.pluginapi import Plugin, ActionInfo, RideLog
from robotide import widgets
Expand All @@ -36,15 +38,25 @@ def __init__(self, app):
})
self._log = []
self._window = None
self._path = os.path.join(tempfile.gettempdir(), 'ride.log')
self._path = os.path.join(
tempfile.gettempdir(), '{}-ride.log'.format(uuid.uuid4()))
self._outfile = None
self._remove_old_log_files()
atexit.register(self._close)

def _close(self):
if self._outfile is not None:
self._outfile.flush()
self._outfile.close()

def _remove_old_log_files(self):
for fname in glob.glob(
os.path.join(tempfile.gettempdir(), '*ride.log')):
try:
os.remove(fname)
except IOError:
pass

@property
def _logfile(self):
if self._outfile is None:
Expand Down

0 comments on commit c689879

Please sign in to comment.