Renames Old Log File if It Exists
This commit is contained in:
@@ -50,10 +50,6 @@ def main():
|
||||
with open(pickle_path) as pickle_file:
|
||||
save = pickle.load(pickle_file)
|
||||
|
||||
output_path = Path(args.outfile)
|
||||
if output_path.exists():
|
||||
output_path.rename(str(output_path) + ".backup")
|
||||
|
||||
except Exception as err:
|
||||
sys.exit(err)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from pathlib import Path
|
||||
import logging
|
||||
|
||||
|
||||
@@ -24,7 +25,9 @@ class Logger:
|
||||
self._logger = logging.getLogger(logger_name)
|
||||
|
||||
def set_logger(self, outfile='run.log', level=logging.INFO):
|
||||
self.outfile = outfile
|
||||
self.outfile = Path(outfile)
|
||||
if self.outfile.exists():
|
||||
self.outfile.rename(str(self.outfile) + ".backup")
|
||||
|
||||
if level is not None:
|
||||
self._logger.setLevel(level)
|
||||
|
||||
Reference in New Issue
Block a user