diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-07-03 08:47:31 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-07-03 08:55:14 +0200 |
commit | 3f2abaf039f94d9a7cd4ba2ef7295c3448985702 (patch) | |
tree | 0cb7e19e979cd012b7793cf27f936251337c3b47 | |
parent | 1da694fe05363bf29359b5290042073774a11f25 (diff) | |
download | ghdl-3f2abaf039f94d9a7cd4ba2ef7295c3448985702.tar.gz ghdl-3f2abaf039f94d9a7cd4ba2ef7295c3448985702.tar.bz2 ghdl-3f2abaf039f94d9a7cd4ba2ef7295c3448985702.zip |
lsp.py: remove oldest file.
Partial work for ghdl-language-server#79
-rw-r--r-- | pyGHDL/cli/lsp.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pyGHDL/cli/lsp.py b/pyGHDL/cli/lsp.py index 951c8b82f..acb65b784 100644 --- a/pyGHDL/cli/lsp.py +++ b/pyGHDL/cli/lsp.py @@ -52,10 +52,18 @@ __loggerName = "ghdl-ls" def __rotate_log_files(basename: str, num: int): """Rotate existing log files.""" + # Remove the oldest file. This one will be lost. + # Required on Windows as it is an error to rename a file to an existing + # one. + oldfile = "{}.{}".format(basename, num) + if os.path.isfile(oldfile): + os.remove(oldfile) + # Rotate old files for i in range(num, 0, -1): oldfile = "{}.{}".format(basename, i - 1) if os.path.isfile(oldfile): os.rename(oldfile, "{}.{}".format(basename, i)) + # Rotate the newest log file. if os.path.isfile(basename): os.rename(basename, "{}.0".format(basename)) |