From 6f9bdf4a7c089014ee457c6ed3f946585d74b97a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 18 Oct 2016 11:28:47 -0400 Subject: [PATCH] Create multiple files on roll conflict Rather than removing the previous file, append a digit to denote extra log files sharing the same roll date. --- confluent_server/confluent/log.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/log.py b/confluent_server/confluent/log.py index e336c9b4..5e7c33a1 100644 --- a/confluent_server/confluent/log.py +++ b/confluent_server/confluent/log.py @@ -444,12 +444,17 @@ class TimedAndSizeRotatingFileHandler(BaseRotatingHandler): # As time rolling happens, reset statistics count self.sizeRollingCount = 0 dbfn = self.binpath + "." + time.strftime(self.suffix, timeTuple) + odbfn = dbfn dtfn = self.textpath + "." + time.strftime(self.suffix, timeTuple) - - if os.path.exists(dbfn): - os.remove(dbfn) - if os.path.exists(dtfn): - os.remove(dtfn) + odtfn = dtfn + append=1 + while os.path.exists(dbfn): + dbfn = odbfn + '.{}'.format(append) + append += 1 + append=1 + while os.path.exists(dtfn): + dtfn = odtfn + '.{}'.format(append) + append += 1 if os.path.exists(self.binpath): os.rename(self.binpath, dbfn) if os.path.exists(self.textpath):